Last active
August 29, 2015 14:11
-
-
Save cowboy/77642d25ef49559d574f to your computer and use it in GitHub Desktop.
AutoHotKey: Poll system for known active windows
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
; =================================================== | |
; Poll system for known active windows | |
; "Cowboy" Ben Alman - 2014 | |
; https://gist.github.com/cowboy/77642d25ef49559d574f | |
; =================================================== | |
#Persistent | |
#SingleInstance Force | |
; Exe windows to poll for. | |
ExeCount = 3 | |
Exe1 = calc.exe | |
Exe2 = explorer.exe | |
Exe3 = chrome.exe | |
LastExe := false | |
SetTimer CheckActive, 100 | |
CheckActive: | |
Loop %ExeCount% { | |
CurrentExe := Exe%A_Index% | |
if (WinActive("ahk_exe" CurrentExe)) { | |
if (CurrentExe != LastExe) { | |
LastExe := CurrentExe | |
ActivateProfile(CurrentExe) | |
} | |
Return | |
} | |
} | |
if (LastExe != false) { | |
LastExe := false | |
ActivateProfile() | |
} | |
Return | |
ActivateProfile(Exe = false) { | |
if (Exe) { | |
TrayTip Active, %Exe%, 0 | |
} else { | |
TrayTip Inactive, No exe detected, 0 | |
} | |
; Do actual stuff here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment