ControlSend command doesn't work completely fine

Ask gaming related questions (AHK v1.1 and older)
julita1255
Posts: 1
Joined: 17 Dec 2017, 18:00

ControlSend command doesn't work completely fine

18 Dec 2017, 05:58

Hi guys, I got some problem with a ControlSend command in game.
Here's (a part of) my script on send commands:

Code: Select all

#MaxThreadsPerHotkey 2
#r::Pause
#f::
loop
{

		send ``
		send x
		send 0
		send z
		send ``
		send 3
		send {space}
		sleep 1100
		send ``
		sleep 1100
		send x
		send 0
		send z
		send ``
		send 4
		send {space}
		sleep 1200
		send ``
		sleep 1200
}
return
and it works completely fine, but I wanted to improve it so I can switch to another window and do some other stuff, cause I haven't got second computer to do so.

I did search how to write script using ControlSend, buuuuuut it appeard not to work completely fine. :headwall:
Here's the new script that works:

Code: Select all

#MaxThreadsPerHotkey 2
wintitle = "Game name"
SetTitleMatchMode, 2
#SingleInstance Force

#r::Pause
#f::
loop
   {
		controlsend,,{Enter}, %wintitle%
		sleep 500
   }
Return
The thing is that this works with the Enter key and other keys like Space bar, numbers and letters seems not to work.

Part of script I tried to use:

Code: Select all

#MaxThreadsPerHotkey 2
wintitle = "Game name"
SetTitleMatchMode, 2
#SingleInstance Force

#r::Pause
#f::
loop
   {
		controlsend,,``, %wintitle%
		controlsend,,x, %wintitle%
		controlsend,,0, %wintitle%
		controlsend,,z, %wintitle%
		controlsend,,``, %wintitle%
		controlsend,,3, %wintitle%
		controlsend,,{space}, %wintitle%
		sleep 1000
		controlsend,,``, %wintitle%
		sleep 300
		controlsend,,x, %wintitle%
		controlsend,,0, %wintitle%
		controlsend,,z, %wintitle%
		controlsend,,``, %wintitle%
		controlsend,,4, %wintitle%
		controlsend,,{space}, %wintitle%
		sleep 1000
		controlsend,,``, %wintitle%
		sleep 300
   }
Return
As I said, this one doesn't work and I don't know why? Any suggestions about how to solve this problem?

EDIT:
In my game the enter key is used to open and close chat and when chat is open keys work completely fine, but they don't work when chat is closed.
So script that works looks like:

Code: Select all

#MaxThreadsPerHotkey 2
wintitle = "Game name"
SetTitleMatchMode, 2
#SingleInstance Force

#r::Pause
#f::
loop
	{
		controlsend,,{enter}, %wintitle%
		sleep 500
		controlsend,,``, %wintitle%
		controlsend,,x, %wintitle%
		controlsend,,0, %wintitle%
		controlsend,,z, %wintitle%
		controlsend,,``, %wintitle%
		controlsend,,3, %wintitle%
		controlsend,,{space}, %wintitle%
		sleep 1000
		controlsend,,``, %wintitle%
		sleep 300
		controlsend,,{enter}, %wintitle%
		sleep 500
	}
Return
Of course I need this working whether the chat is open or not. Is there some way to force that?

EDIT2:
I tried solutions with ahk_parent and ahk_id from other threads and it worked same - only on the chat.
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: ControlSend command doesn't work completely fine

18 Dec 2017, 07:19

julita1255 wrote: Of course I need this working whether the chat is open or not. Is there some way to force that?
No, ControlSend just doesn't work for all games. You'll be lucky if it does. This is a common question and I'm sorry you couldn't find the answers before typing that whole post. I normally suggest running everything in a virtual machine instead if you wish to have a macro running in the background.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 69 guests