Blocking specific keys while a function is running with AutoHotkey

So I made this script with AHK and it works but what I want it to also do, is to make it so while the function is running, it wouldn't be able to be triggered again. So I want to either deactivate the F11 and F12 keys, or make it so the hotkeys are deactivated.

I can't use the BlockInput command, because the Run command starts macroRecorder scripts and if I disable all input, those don't work as well (I tested it)

I'm not familiar with ahk, so I'm stuck here. Any help will be much appreciated.

#SingleInstance force

ShowEN:="TestCasino"
ShowEL:="TestGold"


; Set up the hotkeys

$F11::PlayShow(ShowEN)
$F12::PlayShow(ShowEL)
 

PlayShow(whichShow) {
    
    Run, %whichShow% [, C:\Users\dplyt\Desktop, ]

    return
}

    
Return

Solution 1:

There are two ways to do this....

Method #1 is to use the RunWait command, instead of Run, which will keep the function from exiting immediately after it runs the program (i.e., PlayShow() will wait until the program closes before returning). As long as the RunWait line is executing and the function hasn't returned, the hotkey that triggered it won't retrigger.

Method #2 is to use Method #1 in combination with the Hotkey command to disable/enable one or both hotkeys. If you only want to disable the hotkey that called the routine you can use A_ThisHotkey. If you'd like to disable both of them you can just hard code both of them off/on before and after the call...

#SingleInstance force

ShowEN:="TestCasino"
ShowEL:="TestGold"


; Set up the hotkeys

$F11::PlayShow(ShowEN)
$F12::PlayShow(ShowEL)

PlayShow(whichShow) {
    
    Hotkey, F11,, Off
    Hotkey, F12,, Off
    
    RunWait, %whichShow% [, C:\Users\dplyt\Desktop, ]
    
    Hotkey, F11,, On
    Hotkey, F12,, On

    Return

}
    
Return