#Requires AutoHotkey v2.0 #SingleInstance Force SetTitleMatchMode 2 ; ===================================================================== ; Prompt editor for Visual Studio Code - by Konversaitional (konversaitional.com) ; Write long prompts in a stripped-down, extension-free VS Code, ; paste them back into any text box. ; ; Ctrl+Alt+E in any text box (Claude, ChatGPT, ...) -> open VS Code ; Ctrl+Enter in that VS Code window -> paste back + close ; Ctrl+Alt+Q in that VS Code window -> cancel + close ; ; Uses its own clean VS Code profile: no extensions, no welcome page, ; no updates, no telemetry, no AI chat. Your normal VS Code setup, ; windows and extensions are never touched. ; Free to use and adapt. Run only one of these scripts at a time. ; ===================================================================== ; ----- Settings ------------------------------------------------------ GRAB_EXISTING := true ; true = take the text already in the box along ; and replace it when pasting back ; false = always start with an empty document TRIGGER := "^!e" ; Ctrl+Alt+E CODE := EnvGet("LOCALAPPDATA") "\Programs\Microsoft VS Code\Code.exe" if !FileExist(CODE) CODE := "C:\Program Files\Microsoft VS Code\Code.exe" ; Clean, separate VS Code profile (settings + cache only, never your documents) CODE_DIR := EnvGet("LOCALAPPDATA") "\prompt-editor\vscode" ; --------------------------------------------------------------------- global targetHwnd := 0, editorTitle := "", tmpFile := "" EXE := "Code.exe" Hotkey TRIGGER, OpenEditor OpenEditor(*) { global targetHwnd, editorTitle, tmpFile if editorTitle && WinExist(editorTitle " ahk_exe " EXE) { ; already open WinActivate return } if tmpFile && FileExist(tmpFile) ; leftover try FileDelete tmpFile targetHwnd := WinExist("A") text := GRAB_EXISTING ? GrabText() : "" editorTitle := "prompt_" A_Now ".md" tmpFile := A_Temp "\" editorTitle f := FileOpen(tmpFile, "w", "UTF-8-RAW"), f.Write(text), f.Close() PrepareProfile() ; Own profile + no extensions = own fast process, separate from your VS Code Run '"' CODE '" --new-window --disable-extensions --disable-workspace-trust' . ' --user-data-dir "' CODE_DIR '\data" --extensions-dir "' CODE_DIR '\ext"' . ' "' tmpFile '"' if WinWait(editorTitle " ahk_exe " EXE, , 15) { WinActivate Send "^{End}" } } PrepareProfile() { settings := CODE_DIR "\data\User\settings.json" if FileExist(settings) return DirCreate CODE_DIR "\data\User" DirCreate CODE_DIR "\ext" json := ' ( { "workbench.startupEditor": "none", "workbench.tips.enabled": false, "workbench.enableExperiments": false, "window.restoreWindows": "none", "window.commandCenter": false, "files.hotExit": "off", "files.autoSave": "off", "update.mode": "none", "telemetry.telemetryLevel": "off", "extensions.ignoreRecommendations": true, "extensions.autoCheckUpdates": false, "security.workspace.trust.enabled": false, "chat.disableAIFeatures": true, "editor.wordWrap": "on", "editor.minimap.enabled": false, "workbench.activityBar.location": "hidden", "workbench.statusBar.visible": false, "breadcrumbs.enabled": false } )' f := FileOpen(settings, "w", "UTF-8-RAW"), f.Write(json), f.Close() } #HotIf editorTitle && WinActive(editorTitle " ahk_exe " EXE) ^Enter:: Finish(true) ^!q:: Finish(false) #HotIf Finish(paste) { global editorTitle, tmpFile Send "^s" ; saved -> no "save?" prompt Sleep 300 WinClose editorTitle " ahk_exe " EXE WinWaitClose editorTitle " ahk_exe " EXE, , 5 editorTitle := "" text := FileExist(tmpFile) ? FileRead(tmpFile, "UTF-8") : "" try FileDelete tmpFile if paste PasteBack(text) } ; ----- Shared helpers ------------------------------------------------ GrabText() { saved := ClipboardAll() A_Clipboard := "" Send "^a^c" text := ClipWait(0.4) ? A_Clipboard : "" A_Clipboard := saved return text } PasteBack(text) { if !WinExist("ahk_id " targetHwnd) return WinActivate "ahk_id " targetHwnd WinWaitActive "ahk_id " targetHwnd, , 2 Sleep 100 saved := ClipboardAll() A_Clipboard := RTrim(text, "`r`n") if ClipWait(1) Send GRAB_EXISTING ? "^a^v" : "^v" Sleep 300 A_Clipboard := saved ; restore your clipboard }