Win XBMCLauncher / Launcher4Kodi - All in One Tool for Change Shell, Set Focus and more
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.

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.
Reply


Messages In This Thread
green start button remapping - by Cassiel - 2013-02-12, 21:44
RE: XBMC Launcher - by Govnah - 2013-02-16, 06:32
RE: XBMCLauncher - by MBulli - 2013-02-17, 12:20
RE: XBMCLauncher - All in One Tool for Change Shell, Set Focus and more - by richardb70 - 2014-09-05, 22:57
Launcher4Kodi - by baijuxavior - 2015-02-17, 15:27
lack of focus - by runey71 - 2015-02-18, 07:53
black screen problem - by -CraZed- - 2015-03-18, 06:36
RE: XBMCLauncher / Launcher4Kodi - by TB4875 - 2015-03-25, 11:49
RE: XBMCLauncher / Launcher4Kodi - by kmarq - 2015-05-19, 14:41
Error - by liamp - 2015-05-31, 23:03
RE: XBMCLauncher / Launcher4Kodi - by gitman - 2015-06-07, 21:40
RE: XBMCLauncher / Launcher4Kodi - by RockerC - 2015-06-16, 16:28
RE: Using Tweak UAC - by berkhornet - 2015-07-13, 19:04
RE: - by alsergo - 2015-11-25, 00:11
W10 and netflix - by Cassiuss - 2016-01-10, 15:50
netflix - by Cassiuss - 2016-01-11, 09:11
netflix - by Cassiuss - 2016-01-11, 11:12
netflix - by Cassiuss - 2016-01-11, 13:04
netflix - by Cassiuss - 2016-01-11, 11:44
Reverse shell to explorer - by shayosef - 2016-01-17, 14:24
Launcher4Kodi improvement - by kalhimeo - 2016-01-27, 20:20
resume during recording kodi - by eddedrukker - 2016-04-03, 08:58
RE: XBMCLauncher / Launcher4Kodi - by leezy88 - 2017-02-06, 09:41
Might be of use to someone... - by Grumpy - 2017-09-19, 04:18
Logout Mark Read Team Forum Stats Members Help
XBMCLauncher / Launcher4Kodi - All in One Tool for Change Shell, Set Focus and more20