I am writing an automation script for a game I play a lot, but I am in desperate need of some help with the ControlSend command using Subroutines in relation to Hwnds.
In the following piece of code (note this is only a small part of the script), I use the ControlSend command to send messages to the game after reading coordinates from a certain file:
Code:
runNode:
ControlGet, handle, Hwnd,,, WinTitle ;I wrote WinTitle on purpose
Loop, read, %CoordFile%
{
%direction% = 1
if A_LoopReadLine = 1,0,0,0
{
ControlSend,, A_wSend, ahk_id %handle%
Sleep %timeDelay%
}
else if A_LoopReadLine = EndPath
{
Break
}
else
{
Msgbox, An Error has occured!
}
}
Return
;-----------------------------------------------------------------------------------------------------------------
wSend:
Send {up down}
Sleep 1000
Send {up up}
;-----------------------------------------------------------------------------------------------------------------
Now, here is the issue:
Whenever I write the following it all works perfectly fine: ( the only thing different is the Send x instead of Send {up down} and {up up} )
Code:
runNode:
ControlGet, handle, Hwnd,,, WinTitle ;I wrote WinTitle on purpose
Loop, read, %CoordFile%
{
%direction% = 1
if A_LoopReadLine = 1,0,0,0
{
ControlSend,, A_wSend, ahk_id %handle%
Sleep %timeDelay%
}
else if A_LoopReadLine = EndPath
{
Break
}
else
{
Msgbox, An Error has occured!
}
}
Return
;-----------------------------------------------------------------------------------------------------------------
wSend:
Send x
Sleep 1000
Send x
;-----------------------------------------------------------------------------------------------------------------
But when using the arrow keys (yes, I have tested it using a normal Send command to make sure the keystrokes work in-game) it just does nothing at all.
Can someone explain to me how this is any different ? Or is there something else going on here ?