Created
January 17, 2026 03:19
-
-
Save 4piu/c7cd24545c3ebd6c431f901b744d65ee to your computer and use it in GitHub Desktop.
AutoHotKey example: hotkey activated loop, skip if window not in focus.
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
| #Requires AutoHotkey v2.0 | |
| #SingleInstance Force | |
| #MaxThreadsPerHotkey 2 | |
| windowTitle := "ahk_exe notepad.exe" | |
| #HotIf WinActive(windowTitle) | |
| +F1:: { | |
| static running := false | |
| running := !running | |
| TrayTip(running ? "Running" : "Stopped") | |
| SetTimer TimedLoop, running ? 1000 : 0 | |
| } | |
| TimedLoop() { | |
| if (!WinActive(windowTitle)) { | |
| return | |
| } | |
| Send "{C down}" | |
| Send "{C up}" | |
| Send "{N down}" | |
| Send "{N up}" | |
| Send "{M down}" | |
| Send "{M up}" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment