#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Loop
{
Send, 1
Sleep, 300
Send, 1
Sleep, 5300
Send, 2
Sleep, 8000
Send, 0
Sleep, 200
}
to an application. and i want the hotkey to run even it isnt the active window.
First, this is not correct, Sleep, 300;. See, comments.
Second, I do not see any problems with your ControlSend, you can try to use ahk_parent, see the control parameter of ControlSend. Also consider using SetKeydelay as suggested in the Remarks section of ControlSend.
Finally, note that not all windows accept these kinds of manipulations, you might be out of luck.