Optimus Alpha - TrueCrimeAudit/ClautoHotkey GitHub Wiki

The Model

This is a new "steath" model that has been previewed on OpenRouter to collect testing data. There are rumors that this is either OpenAI's o4-mini or a new Claude Opus model. This uses my standard system prompt for AHK v2. This helps add the basic structure of AHK v2 to agents understanding. You can see this prompt under the Context_Claude.md file.

Snippet Manager Test

The Prompt

There's a little bit of everything in this example to test the LLMs AHK v2 writing abilities. The requirements for this example use some simple patterns. I also look for anything extra that I think wasn't required but showed some level of complexity.

Required:

Initiates class properly (LLMs struggle with appending "new " to classes) Creating a static map Escaping strings Variable scoping Previous window context Control storage Extras:

Fat arrow function

Create an AutoHotkey v2 script for a Snippet Manager tool with the following features:
- Store a collection of predefined text snippets (like greetings, closings, reminders)
- Display them in a listbox GUI
- Allow copying the selected snippet to clipboard
- Option to send the snippet directly to the previous active window
- Show temporary tooltips for user feedback

Additional Requirements:
- Store snippets in a static Map
- Track the previously active window
- Have a clean, resizable GUI
- Display tooltips that automatically disappear

Include these specific snippets: "Greeting", "Closing", "Reminder", and "Follow-up" with appropriate text content for each.
Make sure to follow AutoHotkey v2 best practices with proper event binding, control management, and variable scoping.

The Code

#Requires AutoHotkey v2.1-alpha.17
#SingleInstance Force

SnippetManager()

class SnippetManager {
    static Snippets := Map(
        "Greeting", "Hello, I hope this message finds you well.",
        "Closing", "Best regards,`n[Your Name]",
        "Reminder", "This is a gentle reminder regarding our previous discussion.",
        "Follow-up", "I am following up to see if you had a chance to review my last message."
    )

    __New() {
        this.activeWin := 0
        this.timer := this.SaveActiveWindow.Bind(this)
        SetTimer(this.timer, 500)
        this.CreateGui()
    }

    GetSnippetKeys() {
        keys := []
        for key in SnippetManager.Snippets
            keys.Push(key)
        return keys
    }

    CreateGui() {
        this.gui := Gui("+Resize", "Snippet Manager")
        this.gui.SetFont("s10")
        this.gui.OnEvent("Close", this.HideGui.Bind(this))
        this.gui.OnEvent("Escape", this.HideGui.Bind(this))
        this.gui.OnEvent("Size", this.OnResize.Bind(this))

        keys := this.GetSnippetKeys()
        this.listBox := this.gui.AddListBox("vSnippetListBox w300 h160", keys)
        this.listBox.OnEvent("DoubleClick", this.OnCopy.Bind(this))
        this.listBox.OnEvent("Change", this.OnSelect.Bind(this))

        this.copyBtn := this.gui.AddButton("Default w140", "Copy to Clipboard")
        this.copyBtn.OnEvent("Click", this.OnCopy.Bind(this))

        this.sendBtn := this.gui.AddButton("w140 x+10", "Send to Window")
        this.sendBtn.OnEvent("Click", this.OnSend.Bind(this))

        this.gui.Show("w320 h250")
    }

    OnResize(gui, minMax, w, h) {
        this.listBox.Move(, , w - 20, h - 80)
        this.copyBtn.Move(10, h - 60, 140)
        this.sendBtn.Move(170, h - 60, 140)
    }

    SaveActiveWindow() {
        if WinExist("A")
            this.activeWin := WinGetID("A")
    }

    GetSelectedSnippet() {
        idx := this.listBox.Value
        if idx = 0
            return ""
        keys := this.GetSnippetKeys()
        if idx > keys.Length
            return ""
        key := keys[idx]
        return SnippetManager.Snippets.Has(key) ? SnippetManager.Snippets[key] : ""
    }

    OnSelect(ctrl, *) {
        ; No-op, for event signature completeness
    }

    OnCopy(*) {
        snippet := this.GetSelectedSnippet()
        if snippet {
            A_Clipboard := snippet
            this.ShowTooltip("Snippet copied to clipboard")
        } else {
            this.ShowTooltip("No snippet selected")
        }
    }

    OnSend(*) {
        snippet := this.GetSelectedSnippet()
        if snippet && this.activeWin
        {
            this.gui.Hide()
            WinActivate("ahk_id " this.activeWin)
            Sleep(100)
            SendText(snippet)
            this.ShowTooltip("Snippet sent to window")
            this.gui.Show()
        }
        else if !snippet {
            this.ShowTooltip("No snippet selected")
        } else {
            this.ShowTooltip("No previous window to send to")
        }
    }

    ShowTooltip(msg) {
        ToolTip(msg)
        SetTimer(this.ClearTooltip.Bind(this), -1200)
    }

    ClearTooltip() {
        ToolTip()
    }

    HideGui(*) {
        this.gui.Hide()
    }
}

Errors

Error Set 1

ES_1.1

Error: This value of type "Map" has no method named "Keys".

024: this.gui.OnEvent("Escape", this.HideGui.Bind(this))
025: this.gui.OnEvent("Size", this.OnResize.Bind(this))

▶ 027: this.listBox := this.gui.AddListBox("vSnippetListBox w300 h160", SnippetManager.Snippets.Keys()) 028: this.listBox.OnEvent("DoubleClick", this.OnCopy.Bind(this)) 029: this.listBox.OnEvent("Change", this.OnSelect.Bind(this))

Call stack:

  • (27) : [SnippetManager.Prototype.CreateGui] this.listBox := this.gui.AddListBox("vSnippetListBox w300 h160", SnippetManager.Snippets.Keys())
  • (16) : [SnippetManager.Prototype.__New] this.CreateGui()
  • (4) : [Object.Call] SnippetManager()
  • (4) : [] SnippetManager()

Auto-execute

ES_1.2

Error: This value of type "SnippetManager" has no property named "listBox".

025: this.gui.OnEvent("Size", this.OnResize.Bind(this))
027: this.listBox := this.gui.AddListBox("vSnippetListBox w300 h160", SnippetManager.Snippets.Keys())

▶ 028: this.listBox.OnEvent("DoubleClick", this.OnCopy.Bind(this)) 029: this.listBox.OnEvent("Change", this.OnSelect.Bind(this)) 031: this.copyBtn := this.gui.AddButton("Default w140", "Copy to Clipboard")

Call stack:

  • (28) : [SnippetManager.Prototype.CreateGui] this.listBox.OnEvent("DoubleClick", this.OnCopy.Bind(this))
  • (16) : [SnippetManager.Prototype.__New] this.CreateGui()
  • (4) : [Object.Call] SnippetManager()
  • (4) : [] SnippetManager()

Auto-execute

Error: This value of type "SnippetManager" has no property named "listBox".

027: this.listBox := this.gui.AddListBox("vSnippetListBox w300 h160", SnippetManager.Snippets.Keys())
028: this.listBox.OnEvent("DoubleClick", this.OnCopy.Bind(this))

▶ 029: this.listBox.OnEvent("Change", this.OnSelect.Bind(this)) 031: this.copyBtn := this.gui.AddButton("Default w140", "Copy to Clipboard") 032: this.copyBtn.OnEvent("Click", this.OnCopy.Bind(this))

Call stack:

  • (29) : [SnippetManager.Prototype.CreateGui] this.listBox.OnEvent("Change", this.OnSelect.Bind(this))
  • (16) : [SnippetManager.Prototype.__New] this.CreateGui()
  • (4) : [Object.Call] SnippetManager()
  • (4) : [] SnippetManager()

Auto-execute

ES_1.3

Error: This value of type "SnippetManager" has no property named "listBox".

038: }
040: {

▶ 041: this.listBox.Move(, , w - 20, h - 80) 042: this.copyBtn.Move(10, h - 60, 140) 043: this.sendBtn.Move(170, h - 60, 140)

Call stack:

  • (41) : [SnippetManager.Prototype.OnResize] this.listBox.Move(, , w - 20, h - 80)

Gui

  • (37) : [Gui.Prototype.Show] this.gui.Show("w320 h250")
  • (37) : [SnippetManager.Prototype.CreateGui] this.gui.Show("w320 h250")
  • (16) : [SnippetManager.Prototype.__New] this.CreateGui()
  • (4) : [Object.Call] SnippetManager()
  • (4) : [] SnippetManager()

Auto-execute

ES_2.1

Error: Target window not found.

Specifically: ahk_id 729488

088: {
089: this.gui.Hide()

▶ 090: WinActivate("ahk_id " this.activeWin) 091: Sleep(100) 092: SendText(snippet)

Call stack:

  • (90) : [WinActivate] WinActivate("ahk_id " this.activeWin)
  • (90) : [SnippetManager.Prototype.OnSend] WinActivate("ahk_id " this.activeWin)

Gui