Problem with working in background

Ask gaming related questions (AHK v1.1 and older)
Mariousz
Posts: 6
Joined: 27 Mar 2020, 12:19

Problem with working in background

28 Mar 2020, 10:12

Hi, my name is Mariusz, im in AHK since 1 week and i can make macro that will work only on specific window. I made macro that works but it works only when i have aplication on top
could someone help me with this task that i could do something else while im on pc, here is my code:

#h::
Loop
{
Send {Enter} Landrynka
Sleep, 2500
Send {Enter} Landrynka
}
return

#j::Pause

Window Spy:
Landrynka
ahk_class GAME
ahk_exe Landrynka.exe
ahk_pid 4480
User avatar
Yakshongas
Posts: 590
Joined: 21 Jan 2020, 08:41

Re: Problem with working in background

28 Mar 2020, 10:38

Consider learning a bit about ControlSend if you want to send keys to background windows. :wave:

Code: Select all

#h::

Loop
{
	ControlSend,, {Enter} Landrynka, AHK_exe Landrynka.exe
	Sleep, 2500
	ControlSend,, {Enter} Landrynka, AHK_exe Landrynka.exe
}
return

#j::Pause
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹
Mariousz
Posts: 6
Joined: 27 Mar 2020, 12:19

Re: Problem with working in background

28 Mar 2020, 10:56

but what if i have meny of window with same nickname you know how to implement ahk_pid ?
and can i even do that kind of stuff ?
User avatar
Yakshongas
Posts: 590
Joined: 21 Jan 2020, 08:41

Re: Problem with working in background

28 Mar 2020, 11:00

@Mariousz
Yes just change the "AHK_exe Landryka.exe" with "AHK_pid" and the pid that shows in the window spy.
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹
Mariousz
Posts: 6
Joined: 27 Mar 2020, 12:19

Re: Problem with working in background

28 Mar 2020, 11:04

i think that contolsend don't work in my case any other idea ?
User avatar
Yakshongas
Posts: 590
Joined: 21 Jan 2020, 08:41

Re: Problem with working in background

28 Mar 2020, 11:18

If you have to send text to a specific text field you need to select it first with ControlClick.
Use this script to know the coordinates of the text field:

Code: Select all

CoordMode, Mouse, Relative
Loop
{
	MouseGetPos, posX, PosY
	ToolTip, X: %posX% Y: %posY%
}
ControlClick Works like this:

ControlClick [, Control-or-Pos, WinTitle, WinText, WhichButton, ClickCount, Options, ExcludeTitle, ExcludeText]
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹
Mariousz
Posts: 6
Joined: 27 Mar 2020, 12:19

Re: Problem with working in background

28 Mar 2020, 11:24

it is just that after pressing enter a dialogbox should appear in which you can enter Text but it does not appear
Mariousz
Posts: 6
Joined: 27 Mar 2020, 12:19

Re: Problem with working in background

28 Mar 2020, 11:27

Do you have discord ? That we could tak and show you what do i mean ?
User avatar
Yakshongas
Posts: 590
Joined: 21 Jan 2020, 08:41

Re: Problem with working in background

28 Mar 2020, 11:30

Try getting the focus of the window first.

Code: Select all

#h::

Loop
{
	ControlFocus,, AHK_exe Landrynka.exe
	ControlSend,, {Enter} Landrynka, AHK_exe Landrynka.exe
	Sleep, 2500
	ControlSend,, {Enter} Landrynka, AHK_exe Landrynka.exe
}
return

#j::Pause
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹
User avatar
Yakshongas
Posts: 590
Joined: 21 Jan 2020, 08:41

Re: Problem with working in background

28 Mar 2020, 11:31

@Mariousz
I sent you my discord in a private message
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹
Mariousz
Posts: 6
Joined: 27 Mar 2020, 12:19

Re: Problem with working in background

28 Mar 2020, 11:34

i sended you firend request

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 68 guests