Looking for script running for bakcground game

Ask gaming related questions
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Looking for script running for bakcground game

15 Dec 2017, 20:16

Hello there

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
With manual PID written in script (I want the script to run on a specific client of the game) :

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
Nothing's been working so far and got redirected to this forum where I hope i'll find some help to make this s*it work :)

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)
User avatar
Reloaded
Posts: 273
Joined: 25 Aug 2017, 08:48

Re: Looking for script running for bakcground game

16 Dec 2017, 11:19

Blyat wrote:Hello there

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
With manual PID written in script (I want the script to run on a specific client of the game) :

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
Nothing's been working so far and got redirected to this forum where I hope i'll find some help to make this s*it work :)

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)
You know the Pid change every time when you start and close the App/game? :).
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

16 Dec 2017, 11:28

yes I'm aware, I check everytime before running the whole thing. stil won't work...
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Looking for script running for bakcground game

16 Dec 2017, 13:26

You should also be made aware that ControlSend just doesn't work for every game. In fact many games don't accept it when the game is not in focus.
A_AhkUser
Posts: 884
Joined: 06 Mar 2017, 16:18
Location: France

Re: Looking for script running for bakcground game

16 Dec 2017, 14:06

Hi Blyat,

@Blyat Je répond dans le forum anglais plutôt que dans le forum français; c'est plus simple et ça touche a priori plus de monde.

@others I answer here, for the record, although I could have done it in the francophone sub-forum; actually, this thread is set against the background of this other one where the question was originally answered.

If you want to watch a film in the meanwhile, or, generally speaking, if the window that you peruse in the meanwhile doesn't call interaction you can do something like the following.... however, I wonder whether it is still worthwhile...

Code: Select all

WS_EX_NOACTIVATE := "0x08000000"

Loop, 2
{
run, notepad,,, PID%a_index%
WinWait, % "ahk_pid " . PID%a_index%
AHKID%a_index% := "ahk_id " . WinExist()
WinActivate
}
sleep, 500
WinMaximize % AHKID2
WinRestore % AHKID1
WinMove % AHKID1, 300, 300, 400, 400
WinSet, AlwaysOnTop, On, % AHKID1
WinSet, ExStyle, +%WS_EX_NOACTIVATE%, % AHKID1
Loop, 10
{
ControlSend,, test`r`n, % AHKID2
sleep, 1000
}
WinSet, AlwaysOnTop, Off, % AHKID1
WinSet, ExStyle, -%WS_EX_NOACTIVATE%, % AHKID1
Loop, 2
	PostMessage, 0x112, 0xF060,,, % AHKID%a_index%  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
return
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

16 Dec 2017, 14:32

If u google around u can see that many ppl playing that game USE AHK so there must be a pb somewhere

@AHK_User : If i want to "afk" while running the macro my keyboard macro would just work fine, Im jsut looking for a way to run the macro and actually use keyboard/mice/play smth else in the foreground
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Looking for script running for bakcground game

16 Dec 2017, 14:56

Let me rephrase what I said. ControlSend will not work with Archeage in the background. If you don't believe me you are free to keep searching. Everyone should have dreams.
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

16 Dec 2017, 15:03

Lol I belive you, don't worry, sucks though :/ okay
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

16 Dec 2017, 15:10

Is there any other way to have keys (or abilities/mouseclick/whatever could work) work in the background ?

Virtual Machine ?
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Looking for script running for bakcground game

16 Dec 2017, 15:20

Virtual Machine is my usual goto these days when ControlSend doesn't work. I use to play AA myself and you can see the script I made for healing on https://autohotkey.com/boards/viewtopic.php?f=19&t=551 should be the 4th post down.
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

16 Dec 2017, 15:36

Im getting an old laptop to run my stuff in a week or two. Would u help, after installing a VM, getting two different clients running a script for a very simple controlsend/wait loop on few skills ? Running on two clients, im still extremely rubbish when it comes down to scripting, also never installed VM before
User avatar
joedf
Posts: 6693
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: Looking for script running for bakcground game

17 Dec 2017, 13:24

TygerByte wrote:Virtual Machine is my usual goto these days when ControlSend doesn't work. I use to play AA myself and you can see the script I made for healing on https://autohotkey.com/boards/viewtopic.php?f=19&t=551 should be the 4th post down.
Interesting idea of using a VM... :think: I havent thought of that :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Looking for script running for bakcground game

17 Dec 2017, 15:52

joedf wrote:
TygerByte wrote:Virtual Machine is my usual goto these days when ControlSend doesn't work. I use to play AA myself and you can see the script I made for healing on https://autohotkey.com/boards/viewtopic.php?f=19&t=551 should be the 4th post down.
Interesting idea of using a VM... :think: I havent thought of that :+1:
Yes.. I've even had a weak attempt at trying to get AHK Remote to pass commands to the VM. It's a shame my skills are not good enough.
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

17 Dec 2017, 16:13

By the way, since its a laptop im not gonna touch (not my main computer), would having a client opened on every VM (2 clients opened in focus on different VM) work just by having my old keyboard macro? is AHK really needed in that case ? i could run the corsair macro on each of the client on each of the computer partition ?
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Looking for script running for bakcground game

18 Dec 2017, 05:31

It would work if you can get the software to install.
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

18 Dec 2017, 11:05

Yeah got an old razer mouse to get synapse on a computer.I got no idea how to install a VM gonna google hat around !
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Looking for script running for bakcground game

18 Dec 2017, 11:24

Oh you need Virtualization Technology if you are are going to game on a VM. Should check to see if your CPU supports it first. Without VT you'll find it to be very slow for gaming.
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Looking for script running for bakcground game

18 Dec 2017, 12:26

I actually don't mind, i plan to let the computer run on its own and not evne look at it, could run at 10fps i don't really care

Return to “Gaming”

Who is online

Users browsing this forum: Jianwei and 16 guests