Well.... I repurposed the first menu item in the menu... The updated parts of the code are below. First I had only the prompt text from my above post, then I gave the ai some instructions for a simple ahk v2 gui. And (of course) there were have a dozen errors. Everytime I fixed an error, I added it to the bottom of the prompt text. Then... I restarted the script and gave it the same instructions. I'm glad to say that it didn't make the same mistakes. It did, however, make all new ones. LOL.
Maybe this can be a group project... We can all add the "corrections" that correspond to errors that GPT makes.
Code: Select all
MenuPopup := Menu()
MenuPopup.Add("&1 - Code", Code) ; <---- changed.
MenuPopup.Add("&2 - Summarize", Summarize)
MenuPopup.Add("&3 - Explain", Explain)
MenuPopup.Add("&4 - Expand", Expand)
MenuPopup.Add()
MenuPopup.Add("&5 - Generate reply", GenerateReply)
MenuPopup.Add("&6 - Find action items", FindActionItems)
MenuPopup.Add("&7 - Translate to Spanish", TranslateToSpanish)
Code(*) { ; <---- changed.
ChatGPT_Prompt := "
(
AHK v1 versus AHK v2. Please remember to create AutoHokey v2 code and not AutoHotkey v1 conde. When generating code, create code the conforms to v2 syntax and rultes--Not v1. Here are some examples of the difference.
Function Call Syntax:
AHK v1: FunctionName param1, param2
AHK v2: FunctionName(param1, param2)
Assignment Operator:
AHK v1: var = value
AHK v2: var := value
Variable Dereferencing:
AHK v1: MsgBox % var
AHK v2: MsgBox(var)
If Statements:
AHK v1: If var = value
AHK v2: If (var = value)
Loop Syntax:
AHK v1:
Loop, 10
{
MsgBox % A_Index
}
AHK v2:
Loop 10
{
MsgBox(A_Index)
}
Return Values:
AHK v1: return, value
AHK v2: return value
Expressions:
AHK v1: MsgBox % "Hello " . var
AHK v2: MsgBox("Hello " . var)
Built-in Variables and Functions-Some built-in variables and functions might have been renamed or their behavior changed. For example:
AHK v1: StringLen, OutputVar, InputVar
AHK v2: OutputVar := StrLen(InputVar)
Error Handling:
AHK v1: No specific error handling mechanism.
AHK v2: Use try...catch for error handling.
try {
; Code that might cause an error
} catch e {
MsgBox(e.message)
}
GUI Creation:
AHK v1:
Gui, Add, Text,, Hello
Gui, Show
AHK v2:
Gui := GuiCreate()
Gui.Add("Text", "Hello")
Gui.Show()
Commands vs. Functions:
AHK v1 uses many commands (e.g., MsgBox, Send), while AHK v2 uses functions (e.g., MsgBox(), Send()).
With AHK v2, the correct synyax for creating a GUI is:
mainGui := Gui()
It is not:
mainGui := GuiCreate()
With AHK v2, when using a Fat Arrow function inside an OnEvent, there must be an asterisk, like this:
OnEvent("Close", (*)=>subGui.Destroy())
Not like this:
OnEvent("Close", ()=>subGui.Destroy())
With AHK v2, the second parameter of an OnEvent gui.control.prototype should not have parentheses around it. And the function that gets called must have an asterisk, like this:
myFunction(*)
Not like this:
myFunction()
With AHK v2, Gui.Show() can only have one parameter.
In AHK v2 scripts, '#NoEnv' is no longer used.
In AHK v2, an OnEvent command should look like this:
OnEvent("Click", OpenSecondGui)
Not this:
OnEvent("Button", "Default", Func("OpenSecondGui"))
)"
Status_Message := "Writing Code..."
API_Model := "gpt-4"
ProcessRequest(ChatGPT_Prompt, Status_Message, API_Model, Retry_Status)
}