help making infwinactive working

Get help with using AutoHotkey and its commands and hotkeys
Rlentless
Posts: 11
Joined: 19 Apr 2018, 06:16

help making infwinactive working

19 Apr 2018, 06:28

Hi, I'm trying to make a script that will do a few things, but I can't wrap my head around it.

I'm trying to make a script that holds space all the time, presses F4 and Z every 0.5 second and is only working on a specific .exe without affecting other software.

Code: Select all

#Persistent
SetTimer, PressTheKey, 500
Return

IfWinActive,   ;DivineWorld.exe
   
PressTheKey:
Send, {space down}
Send, {F4 down}
Sleep 10
Send, {F4 up}
Send, {z down}
Sleep 10
Send, {z up}
Return
Pressing works however it's still affecting other open windows than the .exe that I want. Also another question, if I have a few of .exe open with the same name (divineworld.exe in my case), is there a way of making the ahk script affect only one divineworld.exe without affecting another divineworld.exe?
swagfag
Posts: 1547
Joined: 11 Jan 2017, 17:59

Re: help making infwinactive working

19 Apr 2018, 07:07

Code: Select all

PressTheKey:
if (WinActive("ahk_exe DivineWorld.exe")) {
	Send, {space down}
	Send, {F4 down}
	Sleep 10
	Send, {F4 up}
	Send, {z down}
	Sleep 10
	Send, {z up}
}
Return
Rlentless
Posts: 11
Joined: 19 Apr 2018, 06:16

Re: help making infwinactive working

19 Apr 2018, 07:12

swagfag wrote:

Code: Select all

PressTheKey:
if (WinActive("ahk_exe DivineWorld.exe")) {
	Send, {space down}
	Send, {F4 down}
	Sleep 10
	Send, {F4 up}
	Send, {z down}
	Sleep 10
	Send, {z up}
}
Return
That's awesome, thank you very much! Is it possible to have it working on only one exe out of 3 with the same name?
Edit: I just checked it and when i'm tabbed out to another window, the keys are not being pressed in divineworld.exe

Return to “Ask For Help”

Who is online

Users browsing this forum: mloballer, Sabestian Caine and 87 guests