Last active
February 12, 2022 14:57
-
-
Save phense/00e53ab912d504205a9454aca8766a2f to your computer and use it in GitHub Desktop.
ahk-snippets #code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Persistent ; Use this directive to prevent the script from exiting after the auto-execute | |
; section (top part of the script) completes. This is useful in cases where a | |
; script contains timers and/or custom menu items. | |
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
F9:: | |
Stop := 0 | |
Loop { | |
Gosub, ButtonSequence ; execute the button-press sequence | |
Random, TimeToWait, 240000, 600000 ; Get a random number between 4 and 10 minutes (measured in miliseconds) | |
; 240000, 600000 | |
Sleep, %TimeToWait% ; wait for random time | |
} Until Stop | |
return | |
ButtonSequence: ;Function called by SetTimer | |
SendInput 1 | |
Random, Sleeptime, 1000, 2500 | |
Sleep %Sleeptime% | |
SendInput 2 | |
Random, Sleeptime, 1000, 3000 | |
Sleep %Sleeptime% | |
SendInput 3 | |
Random, Sleeptime, 1000, 4000 | |
Sleep %Sleeptime% | |
SendInput 4 | |
return | |
F10::Stop := 1 ; Stop Script by pressing F10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; example of basics | |
#c:: | |
if (winc_presses > 0) ; SetTimer already started, so we log the keypress instead. | |
{ | |
winc_presses += 1 | |
return | |
} | |
; Otherwise, this is the first press of a new series. Set count to 1 and start | |
; the timer: | |
winc_presses := 1 | |
SetTimer, KeyWinC, -400 ; Wait for more presses within a 400 millisecond window. | |
return | |
KeyWinC: | |
if (winc_presses = 1) ; The key was pressed once. | |
{ | |
Run, m:\ ; Open a folder. | |
} | |
else if (winc_presses = 2) ; The key was pressed twice. | |
{ | |
Run, m:\multimedia ; Open a different folder. | |
} | |
else if (winc_presses > 2) | |
{ | |
MsgBox, Three or more clicks detected. | |
} | |
; Regardless of which action above was triggered, reset the count to | |
; prepare for the next series of presses: | |
winc_presses := 0 | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
F9:: ; Start script by Pressing F9 | |
stop := 0 | |
Loop | |
{ | |
Send {d down} ; Press down and hold a for 2 seconds | |
Sleep 2000 | |
Send {d up} | |
Sleep 300000 ; Wait 5 minutes (300.000 ms) | |
}until Stop | |
return | |
F10::Stop := 1 ; Stop Script by pressing F10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment