Thanks a lot for your time, Starship. It works very fine for an active Window, but what I am aiming is for background windows.
I am trying make CTRL work in any window I am using ( even an active instance of the game ) while it does not affect 4 instances of the game that are running in background. The way I am trying to do it now AHK kidnaps CTRL from the whole system, not allowing its use, like this code:
#Requires AutoHotkey v2
pausa := 400
pausa2 := 300
pausa3 := 400
targetPID := 29948
SetKeyDelay -1
SetMouseDelay -1
loopToggle := 0
Home:: Teleporte()
PgUP::global loopToggle := 0
#HotIf WinExist('ahk_exe ragexe.exe')
*LAlt::
*LControl::
*RAlt::
*LShift::
*RControl::Return
#HotIf
Teleporte()
{
global loopToggle := 1
While loopToggle {
ControlSend '{F1}',, "ahk_pid" targetPID
sleep pausa
ControlSend '{F1}',, "ahk_pid" targetPID
sleep pausa
ControlSend '{F1}',, "ahk_pid" targetPID
sleep pausa
ControlSend '{F1}',, "ahk_pid" targetPID
sleep pausa
}
}
It works by not interrupting the execution, but CTRL stops working anywhere.
I tried using
#HotIf WinExist('ahk_pid targetPID')
but this way it does not work as using ahk_exe, the execution is halted while key is pressed.