Please help me to solve this riddle...
My goal is: Suspend script when any program from the list is active (WinActive) or exists (WinExist) and stay suspended untill program is active|exists
Why: Some games need to use buttons I use in everyday life.
I searched forum for solution. Found several solutions for one program. If I reuse those (like copy code for each program - they will start to conflict)
My incomplete solutions:
1. This one has an issue - it unsuspends in each loop when app is not an active one.
Code: Select all
SuspendOnActiveGame:
ProgramList := ["DOOMEternalx64vk.exe", "sw.x64.exe", "Hades.exe","Dishonored.exe","Dishonored2.exe","Deathloop.exe","DaysGone.exe","HorizonZeroDawn.exe","DyingLightGame_x64_rwdi.exe"]
MaxindexProgramList := ProgramList.MaxIndex()
CurrentIndexProgramList := 1
WindowExists := False
While(CurrentIndexProgramList <= MaxindexProgramList) {
ConcatElement := "ahk_exe " . ProgramList[CurrentIndexProgramList]
If WinActive(ConcatElement) and (!A_IsSuspended)
Suspend, On
If !WinActive(ConcatElement) and (A_IsSuspended)
Suspend, Off
CurrentIndexProgramList++
}
return
Code: Select all
While(CurrentIndexProgramList <= MaxindexProgramList) {
ConcatElement := "ahk_exe " . ProgramList[CurrentIndexProgramList]
if WinExist(ConcatElement)
WindowExists := True
if !WinExist(ConcatElement) and (!WindowExists)
WindowExists := False
if (CurrentIndexProgramList == MaxindexProgramList) and (WindowExists) and (!A_IsSuspended)
Suspend, On
if (CurrentIndexProgramList == MaxindexProgramList) and (!WindowExists) and (!A_IsSuspended)
Suspend, Off
}
return