Hold Right Mouse Click Not Working Properly

Get help with using AutoHotkey and its commands and hotkeys
User avatar
TokiSciFi
Posts: 11
Joined: 20 May 2020, 23:05

Hold Right Mouse Click Not Working Properly

23 May 2020, 14:43

I want to say thanks to all of you guys for your intellect and recommendations. I am not a coder at all and thanks to you all I've been able to create a script that works beautiful. I have one little problem with the last script created. This script supposed to hold down mouse-right-click until I release one of the four arrow keys. It works, it just does not hold down mouse-right-click every time. I have bind these arrows to the game movement Forward, Backwards, Strafe Left, Strafe Right. When I'm using the arrows to move my toon the script will hold down mouse right click but not all the time. Sometimes the cursor disengage from being held. Is there something wrong in the script?

SetMouseDelay,-1
~*Up::
Send, {RButton Down}
keywait,% SubStr(A_ThisHotkey,3)
Send, {RButton Up}
Mousemove,% A_ScreenWidth / 2,% A_ScreenHeight / 2
Return

SetMouseDelay,-1
~*Left::
Send, {RButton Down}
keywait,% SubStr(A_ThisHotkey,3)
Send, {RButton Up}
Mousemove,% A_ScreenWidth / 2,% A_ScreenHeight / 2
Return

SetMouseDelay,-1
~*Down::
Send, {RButton Down}
keywait,% SubStr(A_ThisHotkey,3)
Send, {RButton Up}
Mousemove,% A_ScreenWidth / 2,% A_ScreenHeight / 2
Return

SetMouseDelay,-1
~*Right::
Send, {RButton Down}
keywait,% SubStr(A_ThisHotkey,3)
Send, {RButton Up}
Mousemove,% A_ScreenWidth / 2,% A_ScreenHeight / 2
Return
vsub
Posts: 470
Joined: 29 Sep 2015, 03:39

Re: Hold Right Mouse Click Not Working Properly

23 May 2020, 16:32

Why did you change the code like that?
What I posted in the other thread(where you should have continued)is doing the exact same thing but without the need of the duplicated code

My question is,without using the script does what you want to do actually work if you hold the right mouse button and press any of the arrow keys
Do you want to do something like right click and hold and move the mouse up\down\left\right
User avatar
TokiSciFi
Posts: 11
Joined: 20 May 2020, 23:05

Re: Hold Right Mouse Click Not Working Properly

23 May 2020, 18:48

vsub wrote:
23 May 2020, 16:32
Why did you change the code like that?
What I posted in the other thread(where you should have continued)is doing the exact same thing but without the need of the duplicated code

My question is,without using the script does what you want to do actually work if you hold the right mouse button and press any of the arrow keys
Do you want to do something like right click and hold and move the mouse up\down\left\right
Sir, your code worked just fine. I have a different problem with the script thats why I posted in a new post.
User avatar
Scr1pter
Posts: 1193
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Hold Right Mouse Click Not Working Properly

23 May 2020, 20:04

@TokiSciFi:
Do yourself a favor and change the structure of your code to vsub's one.
Especially as a beginner you will quickly lose the overview when copying and pasting code blocks.
You have to apply changes X times, rather than just 1 time.

I think the problem is that once you release any of these 4 keys, the rbutton will not be held anymore.
You need some rule that the rbutton will only be released if none of the 4 keys is pressed.

But it's too late now to check it deeper (3 am)

Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G15 FE - Mice: Logitech G9 FE, G502 FE, G602, Jelly Comb Touchpad - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.32.00
User avatar
TokiSciFi
Posts: 11
Joined: 20 May 2020, 23:05

Re: Hold Right Mouse Click Not Working Properly

23 May 2020, 21:14

Currently, I am playing WoW and GW2. The movement in these two games are pretty much the same, QWES keyboard keys for movement and hold down right click to rotate camera. Now, I bind QWES to the arrow keys to have AutoHotkey software not interfering when Im typing in the chat.

Up arrow = Forward
Down arrow = backward
Left arrow = strafe left
Right arrow = strafe right

I am looking into this script because I play WoW and GW2 with an Xbox One controller remapped with the ReWASD software. In order to play with a controller I have to hold down the designated remapped controller button for mouse right click constantly. This script Im trying to create will help me to not hold down that controller button all the time.

Now, the code is like this following @vsub advice:

SetMouseDelay,-1
~*Up::
~*Left::
~*Down::
~*Right::
Send, {RButton Down}
keywait,% SubStr(A_ThisHotkey,3)
Send, {RButton Up}
Mousemove,% A_ScreenWidth / 2,% A_ScreenHeight / 2
Return

Now, while moving my toon in GW2 I notice that the mouse-right-click wont hold. Also, the cursor will recenter sometimes, not every time I release the key.
User avatar
TokiSciFi
Posts: 11
Joined: 20 May 2020, 23:05

Re: Hold Right Mouse Click Not Working Properly

24 May 2020, 00:50

I've been reading a lot and I still stuck. I think I can resolve the problem of mouse-right-click not been held all the time, by adding settimer instead keywait. Basically, to tell Autohotkey if no Up Down Left Right arrow is held for X amount of time then release mouse-right-click. How can that be done?

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler, Google [Bot], rhaos, Sabestian Caine, Sefrautic, slupka and 36 guests