First of all, i'm a complete noob when it comes down to AHK/scripting. I am basically looking for Hotkeys to be sent to a game running in the background (my corsair macro would only work for window that has focus, which means, I can't uyse my compouter anymore or do anything else).
The game is ArcheAge and I want a client running in the back to ahve key strokes sent so it does its stuff on its own, without having window focus. I have tried these methods with no success :
With PID detection :
Code: Select all
#NoEnv
SendMode Input
#SingleInstance force
SetKeyDelay, 0, 50
#IfWinExist ahk_exe ArcheAge.exe
^j::
WinGet, PID, PID, ahk_exe ArcheAge.exe
AHKID := "ahk_id " . WinExist("ahk_pid " . PID)
Loop {
ControlSend,, {s down} ; , % AHKID
Sleep, 1000
ControlSend,, {s up} ; , % AHKID
sleep, 1000
ControlSend, ahk_parent, {s down} ; , % AHKID
Sleep, 1000
ControlSend, ahk_parent, {s up} ; , % AHKID
sleep, 1000
}
return
#If
F10::ExitApp
Code: Select all
#NoEn
SetWorkingDir %A_ScriptDir%
SendMode InputThenPlay
F10::ExitApp
Loop
{
ControlSend, , {Alt down}, ahk_pid 9780
Sleep, 90
ControlSend, , {2 down}, ahk_pid 9780
Sleep, 160
ControlSend, , {2 up}, ahk_pid 9780
Sleep, 40
ControlSend, , {Alt up}, ahk_pid 9780
Sleep, 1000
ControlSend, , {1 down}, ahk_pid 9780
Sleep 15500
ControlSend, , {1 up}, ahk_pid 9780
Sleep 1000
ControlSend, , {F down}, ahk_pid 9780
Sleep, 170
ControlSend, , {F up}, ahk_pid 9780
Sleep 100
ControlSend, , {4 down}, ahk_pid 9780
Sleep 200
ControlSend, , {4 up}, ahk_pid 9780
Sleep 3500
ControlSend, , {S down}, ahk_pid 9780
Sleep 10
ControlSend, , {S up}, ahk_pid 9780
}
Return
The keysstrokes I want to be sent are :
AZERTY keyboard layout
Press "ALT"
wait 90ms
Press "é" (or 2)
wait 160ms
Release "é" (or 2)
wait 40ms
Release "ALT"
wait 1000ms
HOLD "&" (or 1) for 15500ms
Release "&"
wait 1000ms
Press "F"
wait 170ms
Release "F"
wait 100ms
Press ' (apostrophe, or 4)
wait 200ms
Release ' (apostrophe or 4)
wait 3500ms
Press "S"
wait 10ms
Release "S"
repeat endless loop with a key to stop the script if needed
EDIT : I've ran the Send and Click Tool and Send and ControlSend would ONLY work if I got focus of the window im testing. If alt tabbing, Noone of the commands seems to work (Mouse and keys)