AI_PROOFREADING_PROMPT := "You are an experienced appellate attorney working for a state supreme court. You are careful and precise in your writing. Proofread the following text and propose edits to improve it. Focus on grammar, clarity, conciseness, and professional tone. Apply style suggestions consistent with Bryan Garner's Redbook. As additional style suggestions, consider in priority order: (1) the style reflected in opinions by Jerod Tufte of the North Dakota Supreme Court; (2) Ross Guberman's Point Taken; (3) the style of Justice Neil Gorsuch, Elena Kagan, and Clarence Thomas. For all citations to authority, check for consistency with Bluebook format. Avoid passive voice unless that makes the sentence worse or less readable. Make note of any potential dicta and unnecessary alternative rationales. Point out any potential ambiguity, especially consider potential criticism from someone who may disagree with the decision and point out passages that may be easily quoted out of context. Never use plural pronouns as a gender neutral singular -- use he, she, or it, or rephrase to avoid the pronoun. Never use and/or, never use legalese like herein, wherefore, or latin-derived words when a plain English word carries the necessary precision. Always refer to constitutions as protecting, guaranteeing, or preserving rights, and never as creating or granting them unless the text clearly declares a newly created right. Check for any logical fallacies. Use the Oxford comma where appropriate. Your response should start with the proposed revised version set off by --Begin Revised Version-- and --End Revised Version-- followed by your analysis, your explanation for changes, and any other comments that may assist the court. Please bold any words that are changed to distinguish those from passages you would not suggest changing.`n`n" ;; ========================================================================== ;; CLAUDE AI INTEGRATION MODULE ;; ========================================================================== ^#!c:: ; Ctrl+Win+Alt+C - Send selected text to Claude for proofreading { ; Save current clipboard content ClipSaved := ClipboardAll() ; Clear the clipboard A_Clipboard := "" ; Send Ctrl+C to copy the selected text Send "^c" ; Wait for the clipboard to contain text with a longer timeout if !ClipWait(2) { MsgBox "No text was selected!" ; Restore original clipboard A_Clipboard := ClipSaved return } ; Get the selected text from clipboard selectedText := A_Clipboard ; Prepare the prompt for Claude using global definition promptText := AI_PROOFREADING_PROMPT . selectedText ; Save current mouse position MouseGetPos &xpos, &ypos ; Check if Claude is already open in a browser tab claudeFound := false ; Try to find Claude tab in common browsers for browserClass in ["Chrome_WidgetWin_1", "MozillaWindowClass", "ApplicationFrameWindow"] ; Chrome, Firefox, Edge { if WinExist("ahk_class " . browserClass) { ; Activate the browser window WinActivate Sleep 500 ; Try to find Claude tab by checking window titles windowList := WinGetList("ahk_class " . browserClass) for window in windowList { title := WinGetTitle("ahk_id " . window) if InStr(title, "Claude") || InStr(title, "claude.ai") { WinActivate("ahk_id " . window) claudeFound := true Sleep 1000 break } } if claudeFound break } } ; If no Claude tab found, open a new one if !claudeFound { Run "https://claude.ai/" ; was /new but that seems to have triggered some automation blocker ; Wait longer for the page to load - especially important on slower connections Sleep 3000 ; Wait for any browser window to become active try { WinWait "ahk_group Browsers",, 10 } catch { MsgBox "Couldn't detect browser window after 10 seconds. Try again." A_Clipboard := ClipSaved ; Restore clipboard return } ; Make sure the window is active WinActivate "ahk_group Browsers" Sleep 1000 } ; Set clipboard to the prompt text A_Clipboard := promptText Sleep 500 ; Try to focus the input field using Tab then Shift+Tab ; This works better in Vivaldi and other browsers for Claude's interface Sleep 1000 ; Wait a bit for the page to finish rendering Send "{Tab}" ; Tab once Sleep 300 Send "+{Tab}" ; Shift+Tab to focus the input field Sleep 500 ; Now try to paste Send "^v" Sleep 500 ; Press Enter to send the message Send "{Enter}" ; Restore original clipboard after a delay Sleep 1000 A_Clipboard := ClipSaved ; Restore original mouse position MouseMove xpos, ypos ; Show notification ToolTip "Text sent to Claude for proofreading!" SetTimer () => ToolTip(), -2000 ; Hide tooltip after 2 seconds } ;; ========================================================================== ;; GOOGLE GEMINI INTEGRATION MODULE ;; ========================================================================== ^#!g:: ; Ctrl+Win+Alt+G - Send selected text to Google Gemini for proofreading { ; Save current clipboard content ClipSaved := ClipboardAll() ; Clear the clipboard A_Clipboard := "" ; Send Ctrl+C to copy the selected text Send "^c" ; Wait for the clipboard to contain text with a longer timeout if !ClipWait(2) { MsgBox "No text was selected!" ; Restore original clipboard A_Clipboard := ClipSaved return } ; Get the selected text from clipboard selectedText := A_Clipboard ; Prepare the prompt for Gemini using global definition (same as Claude for consistency) promptText := AI_PROOFREADING_PROMPT . selectedText ; Save current mouse position MouseGetPos &xpos, &ypos ; Check if Gemini is already open in a browser tab geminiFound := false debugInfo := "Debug: Searching for existing Gemini tabs...`n" ; Try to find Gemini tab in common browsers for browserClass in ["Chrome_WidgetWin_1", "MozillaWindowClass", "ApplicationFrameWindow"] ; Chrome, Firefox, Edge { if WinExist("ahk_class " . browserClass) { debugInfo .= "Found browser class: " . browserClass . "`n" ; Activate the browser window WinActivate Sleep 500 ; Try to find Gemini tab by checking window titles windowList := WinGetList("ahk_class " . browserClass) debugInfo .= "Found " . windowList.Length . " windows for this browser`n" for window in windowList { title := WinGetTitle("ahk_id " . window) debugInfo .= "Window title: " . title . "`n" ; More comprehensive Gemini detection if InStr(title, "Gemini") || InStr(title, "gemini.google.com") || InStr(title, "Google AI") { WinActivate("ahk_id " . window) geminiFound := true debugInfo .= "Found existing Gemini tab!`n" Sleep 1000 break } } if geminiFound break } } ; Show debug info with temporary tooltip if !geminiFound { ToolTip debugInfo SetTimer () => ToolTip(), -5000 ; 5 second display } ; If no Gemini tab found, open a new one if !geminiFound { ToolTip "No existing Gemini tab found. Opening new tab..." SetTimer () => ToolTip(), -2000 Run "https://gemini.google.com/" ; Wait longer for the page to load Sleep 4000 ; Increased wait time ; Wait for any browser window to become active try { WinWait "ahk_group Browsers",, 15 ; Increased timeout } catch { MsgBox "Couldn't detect browser window after 15 seconds. Try again." A_Clipboard := ClipSaved ; Restore clipboard return } ; Make sure the window is active WinActivate "ahk_group Browsers" Sleep 1000 } ; Set clipboard to the prompt text A_Clipboard := promptText Sleep 500 ; Focus the input field for Gemini using Ctrl+F search method Sleep 2000 ; Wait for page to finish rendering ; Use Ctrl+F to search for "Tools" and navigate backwards to input field Send "^f" ; Open find dialog Sleep 300 Send "Tools" ; Search for Tools button Sleep 300 Send "{Enter}" ; Find it Sleep 500 Send "{Escape}" ; Close find dialog Sleep 300 ; Navigate backwards twice to reach the input field Send "+{Tab}+{Tab}" Sleep 500 ; Paste the prompt text A_Clipboard := promptText Sleep 200 Send "^v" Sleep 500 Sleep 500 ; Try to send the message ; Gemini typically uses Enter, but let's try both Send "{Enter}" Sleep 1000 ; If Enter didn't work, try Ctrl+Enter Send "^{Enter}" ; Restore original clipboard after a delay Sleep 1000 A_Clipboard := ClipSaved ; Restore original mouse position MouseMove xpos, ypos ; Show notification ToolTip "Text sent to Google Gemini for proofreading!" SetTimer () => ToolTip(), -2000 ; Hide tooltip after 2 seconds }