Right click sometimes doesn't work for game

Ask gaming related questions (AHK v1.1 and older)
scttskyler
Posts: 4
Joined: 16 Feb 2024, 16:15

Right click sometimes doesn't work for game

Post by scttskyler » 16 Feb 2024, 16:23

Hi all,

I made a script to assist me in a game, in the script, there is 4 points that should be right-clicked. However, sometimes the mouse will move, but not trigger the right-click. What could be causing this? I tried this on a regular browser window and everything seems to work fine.

Here is a snipit of the section I'm using for the right-clicks. There is more code if additional info is required:

Code: Select all

menuMove := 0

Ctrl & q::
{
mouseclick, right, 2141, 1178, 1, 0
menuMove := 41
}
return
Ctrl & w::
{
mouseclick, right, 2353, 1178, 1, 0
menuMove := 41
}
return
Ctrl & e::
{
mouseclick, right, 2141, 1374, 1, 0
menuMove := 41
}
return
Ctrl & r::
{
mouseclick, right, 2353, 1374, 1, 0
menuMove := 41
}
[Mod edit: moved from AHK v2 help since this is v1 code.]
User avatar
Gubna
Posts: 29
Joined: 29 Nov 2021, 09:00
Contact:

Re: Right click sometimes doesn't work for game

Post by Gubna » 16 Feb 2024, 17:28

Games can be finnicky to get keypresses or clicks to be sent properly.

There are two methods that have worked in the past for games.

Code: Select all

click x y right
or

Code: Select all

mousemove, x, y
click right
Some trial and error with different send methods/events will help figure out if AHK works with your particular game.
scttskyler
Posts: 4
Joined: 16 Feb 2024, 16:15

Re: Right click sometimes doesn't work for game

Post by scttskyler » 16 Feb 2024, 20:00

I'll try it out. Question about the forum I'm in, though. I downloaded version 2 but I was moved to version 1 forum?
scttskyler
Posts: 4
Joined: 16 Feb 2024, 16:15

Re: Right click sometimes doesn't work for game

Post by scttskyler » 16 Feb 2024, 20:33

the mouse move then click seems to have a pretty high success rate, but it still misses sometimes. Even adding a delay of 150 with sleep doesn't help. At that point I might as well just be clicking it myself.

So what causes this to happen? Should I start testing out other sending methods?
gregster
Posts: 9114
Joined: 30 Sep 2013, 06:48

Re: Right click sometimes doesn't work for game

Post by gregster » 16 Feb 2024, 21:16

scttskyler wrote:
16 Feb 2024, 20:00
Question about the forum I'm in, though. I downloaded version 2 but I was moved to version 1 forum?
Like the note says, the posted code looks like v1 code (v2 syntax is different). It would even error out on current v2. If you are running this code, you are using v1.

In v2, you wouldn't need the returns, since all hotkeys are now functions, and the braces would suffice - and the syntax for MouseClick would be different: compare MouseClick examples. In v2, there could also be a variable scope problem, assuming that the variable menuMove actually gets used for something.

Generally, in either version, I would recommend to use the ^ modifier for hotkeys involving the Ctrl key. This means: ^q:: instead of Ctrl & q::.
But all this is not specifically related to your gaming question.
User avatar
Gubna
Posts: 29
Joined: 29 Nov 2021, 09:00
Contact:

Re: Right click sometimes doesn't work for game

Post by Gubna » 17 Feb 2024, 07:59

scttskyler wrote:
16 Feb 2024, 20:33
the mouse move then click seems to have a pretty high success rate, but it still misses sometimes. Even adding a delay of 150 with sleep doesn't help. At that point I might as well just be clicking it myself.

So what causes this to happen? Should I start testing out other sending methods?
I don't have the specific answer as to why this happens, but from experience with getting presses to work in-game you may need to try another method here. Making the keypress or button click last longer to be registered in-game may help.

Code: Select all

mousemove, x, y
sleep 50
Send {RButton Down}
sleep 50
Send {Rbutton Up}
scttskyler
Posts: 4
Joined: 16 Feb 2024, 16:15

Re: Right click sometimes doesn't work for game

Post by scttskyler » 18 Feb 2024, 15:18

Just to add to the weirdness of this, the right click does work everywhere else in the game, it only is not working properly on these specific buttons that I'm trying to click.

At this point I'm at a loss and don't know what to do to make it work. I've even isolated the code to just simply "right click" wherever I have the mouse hovering, and it still has issues. I appreciate the help.
Post Reply

Return to “Gaming Help (v1)”