2014-09-05, 22:57
Hi, many thanks to the OP for the excellent work, and also for getting me into AHK scripting which has been a massive saviour. I'm running loads of emulators and PC games and AHK has been a real life saver with key remaps and using a 360 controller to terminate programs etc.
Anyway, I posted earlier about running out of the 4 slots for external players. Ran through the code (very nice job, BTW) and made a few changes for ease of accommodating additional .exes. Thought I'd share if anyone else is interested.
The last two lines are mine. If you run out of slots, you want the OtherExternalPlayers variable to hold a comma-separated list of the .exes - not the full file paths, this is important.
Add the LoadUpArray function down below in the function area:
This takes values from the GUI slots as well as the comma-separated variable and puts all of them into an array.
Now tweak DisableFocusOnExternalPlayer so that you have:
Up to you if you do like me and surgically remove the rest of it. I'm only using the External Players and not the Prevent Focus Apps, so this will do me. At the very least you want to comment out (or remove) the blocks with ExternalPlayer1 - 4 in them as these are already taken care of.
It's slightly more efficient in that the paths are already stripped out so no need to call SplitPath every iteration of the timer, and also it will terminate after a running process is found rather than continuing to check other processes.
Anyway, there you go, feedback welcome and many thanks again to baijuxavior.
Anyway, I posted earlier about running out of the 4 slots for external players. Ran through the code (very nice job, BTW) and made a few changes for ease of accommodating additional .exes. Thought I'd share if anyone else is interested.
Code:
global ExternalPlayerRunning = 0
global ExternalPlayer1 := GetSettings("ExternalPlayer1_Path", "")
global ExternalPlayer2 := GetSettings("ExternalPlayer2_Path", "")
global ExternalPlayer3 := GetSettings("ExternalPlayer3_Path", "")
global ExternalPlayer4 := GetSettings("ExternalPlayer4_Path", "")
global ExternalPlayerName = ""
global FocusExternalPlayer := GetSettings("FocusExternalPlayer", 0)
global OtherExternalPlayers := "Hello4.exe,Hello5.exe" ; EDIT HERE TO ADD NEW .EXE FILES
global ExternalPlayerArray := LoadUpArray()
The last two lines are mine. If you run out of slots, you want the OtherExternalPlayers variable to hold a comma-separated list of the .exes - not the full file paths, this is important.
Add the LoadUpArray function down below in the function area:
Code:
LoadUpArray()
{
global ExternalPlayer1
global ExternalPlayer2
global ExternalPlayer3
global ExternalPlayer4
global OtherExternalPlayers
ExternalPlayerArray := Object()
Loop, 4
{
if (ExternalPlayer%A_Index% != "")
{
SplitPath, ExternalPlayer%A_Index%, filnam
; MsgBox Load: The filename is %filnam%
ExternalPlayerArray.Insert(filnam)
}
}
StringSplit, tempArray, OtherExternalPlayers, `,
Loop, %tempArray0%
{
filnam := tempArray%A_index%
; MsgBox Load: The filename is %filnam%
ExternalPlayerArray.Insert(filnam)
}
return ExternalPlayerArray
}
This takes values from the GUI slots as well as the comma-separated variable and puts all of them into an array.
Now tweak DisableFocusOnExternalPlayer so that you have:
Code:
DisableFocusOnExternalPlayer()
{
global ExternalPlayerRunning
global ExternalPlayerArray
global ExternalPlayerName
ExternalPlayerRunning = 0
for index, playername in ExternalPlayerArray
{
; MsgBox Use: the playername is %playername%
Process, exist, %playername%
If (ErrorLevel >= 1)
{
ExternalPlayerRunning = 1
ExternalPlayerName = %playername%
break
}
}
}
Up to you if you do like me and surgically remove the rest of it. I'm only using the External Players and not the Prevent Focus Apps, so this will do me. At the very least you want to comment out (or remove) the blocks with ExternalPlayer1 - 4 in them as these are already taken care of.
It's slightly more efficient in that the paths are already stripped out so no need to call SplitPath every iteration of the timer, and also it will terminate after a running process is found rather than continuing to check other processes.
Anyway, there you go, feedback welcome and many thanks again to baijuxavior.