Hello there ✌
Me and my Tudor like to work with "Settimer". And variables to toggle things on and off
Code: Select all
#Requires AutoHotkey v2.0 ; Script requires AutoHotkey V2
#SingleInstance Force ; When this script launches, if it was already running, it will close the previous one
F4:: { ; <- F4 Hotkey to Toggle between Timer On and Timer Off
Static on := False
if on := !on {
ComObject("SAPI.SpVoice").Speak("Function On")
SetTimer(PutInHereYourFunctionName, 500) ; <- repeating checks if function on each "500" milliseconds
} else {
SetTimer(PutInHereNameOfFunction, 0) ; 0 = Off
ComObject("SAPI.SpVoice").Speak("Function Off") ; Speaks the Text "Function Off" you can "put in here your own text"
}
The Next thing I like to use is the code part
Code: Select all
if WinActive("PutInHereYourWindowTitle") {
code lines in here
}
to make things only active if a specified window is open (like Microsoft-Word is open)
Last thing I liked was, let something NOT be active while I am working, was "idle check" so script waits until my computer is longer then xxx seconds into "idle" to make the action you do a auto repeating Settimer on the top and then you do the function with if A_TimeIdle < xxxx milliseconds on it.
This example here moves my mouse after around 20 seconds inactivity
Code: Select all
#Requires AutoHotkey v2.0 ; Script requires AutoHotkey V2
#SingleInstance Force ; When this script launches, if it was already running, it will close the previous one
SetTimer(MouseMove, 1000) ; starts the function every x milliseconds (1 second)
MouseMove() {
if A_TimeIdle >= 15000 { ; (15000 = 15 seconds) Checks if PC was in Idle for x sec then activate following Function
MouseMove Random(-1000,1000), Random(-1000,1000), Random(100), "R" ; RandomMouseMove across x and x Pixel
}
}
I recomend you to google the functions in the docs and maybe check for "Visual Studio Code" as Script Editor Programm,
You just need to install the AHK Language Packs
But you can also google that (Visual Studio AHKv2 Language.