This thread will be dedicated to creating AutoHotkey scripts. For all my requests please…
- User
This thread will be dedicated to creating AutoHotkey scripts. For all my requests please use the following preferences • When assigning a value to a variable use := I.e. myVar:=”blah”. • Camel case all created variables and make sure they are at between 5 and 25 characters long. • Camel case all functions and classes. The names should be long and clearly explain what they do. • Do not use external libraries or dependencies. • Every function used should be implemented in the script. • Function and class definitions should be at the end of the script. • Annotate all provided code with inline comments explaining what they do to a beginner programmer. • When possible, use AutoHotkey functions over AutoHotkey commands. • When possible, Force an expression: I.e. use msgbox % “hi ” var instead of msgbox hi %var% • I prefer less-complicated scripts, that might be longer, over denser, more advanced, solutions. • Use One True Brace formatting for Functions, Classes, loops, and If statements. • Write the code for the current authotkey v1 language. • Be factual. Add at the beginning of each script • #Requires Autohotkey v1.1.36+ • #SingleInstance, Force ;Limit one running version of this script • #NoEnv ;prevents empty variables from being looked up as potential environment variables • DetectHiddenWindows, On ;ensure can find hidden windows • ListLines On ;on helps debug a script-this is already on by default • SendMode, Input ; Recommended for new scripts due to its superior speed and reliability. • SetBatchLines, -1 ;run at maximum CPU utilization • SetWorkingDir, % A_ScriptDir ;Set the working directory to the scripts directory • SetTitleMatchMode 2 ;Sets matching behavior of the WinTitle parameter in commands such as WinWait- 2 is match anywhere • Always use the PCRE regex engine for regular expressions The following hotkeys should be added after the AutoExecute section of the script a • ^+e::Edit ;Control+Shift+E to Edit the current script • ^+Escape::Exitapp ;Control Shift + Escape will Exit the app • ^+r::Reload ;Reload the current script
Assistant
Sure! Here's an example AutoHotkey script that implements the preferences you specified:
; Requires AutoHotkey v1.1.36+ #SingleInstance, Force #NoEnv DetectHiddenWindows, On ListLines, On SendMode, Input SetBatchLines, -1 SetWorkingDir, %A_ScriptDir% SetTitleMatchMode, 2
; Variables myVar1 := "hello world" myVar2 := 10 myVar3 := "this is a test"
; Functions Func1() { ; Camel case function name ; Long and clear explanation of what it does ; One True Brace formatting If myVar1 = "hello world" { ; Annotate the code with inline comments ; Use AutoHotkey functions when possible MsgBox, % "The value of myVar1 is: " myVar1 } else { ; Use a less complicated solution Loop, % myVar2 { ; Use AutoHotkey functions when possible If StringMatch(myVar3, "%A_LoopCounter%") { ; Use a factual comment ; Comment explaining why the code is needed return } } } return }
; Classes Class1 { ; Camel case class name Member1() { ; Camel case member function name ; Use AutoHotkey functions when possible MsgBox, % "The value of Member1 is: " this return } }
; End of script #NoEnv return
; Function and class definitions Func1() { ; One True Brace formatting If myVar1 = "hello world" { ; Annotate the code with inline comments ; Use AutoHotkey functions when possible MsgBox, % "The value of myVar1 is: " myVar1 } else { ; Use a less complicated solution Loop, % myVar2 { ; Use AutoHotkey functions when possible If StringMatch(myVar3, "%A_LoopCounter%") { ; Use a factual comment ; Comment explaining why the code is needed return } } } return }
Class1 { ; Camel case class name Member1() { ; Camel case member function name ; Use AutoHotkey functions when possible MsgBox, % "The value of Member1 is: " this return } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.