Please help with mouse cursor move and pressing down Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Laszlo
Posts: 7
Joined: 25 May 2022, 02:48

Please help with mouse cursor move and pressing down

Post by Laszlo » 25 May 2022, 02:54

Hello sir,

when I keep pressing down the Right mouse button, I'd like to do so at the center of the screen.
for that I made so far only:

RButton::MouseMove,959,539

to this, I'd like to add a function that also keeps pressing down the right mouse button, not only moving it to the center of the screen.
Can someone PLEASE HELP?

Thanks.

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: PLEASE HELP with mouse cursor move and pressing down

Post by WalkerOfTheDay » 25 May 2022, 03:07

?

Code: Select all

RButton::MouseClick, Right, 959,539, 1, 50, D

Laszlo
Posts: 7
Joined: 25 May 2022, 02:48

Re: PLEASE HELP with mouse cursor move and pressing down

Post by Laszlo » 25 May 2022, 03:25

OH... that works, however, can you make the code that keeps pressing down when and only when i keep pressing the button PLEASE?

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: PLEASE HELP with mouse cursor move and pressing down

Post by WalkerOfTheDay » 25 May 2022, 03:53

Laszlo wrote:
25 May 2022, 03:25
OH... that works, however, can you make the code that keeps pressing down when and only when i keep pressing the button PLEASE?
Well, this code will release the held down button, but ! when you press it again it will immidiately get held in again.
I don't know if this is the desired behaviour ? Can you explain a bit more about what you are trying to do ?
Are you using certain software in which you need to hold the right mouse button while moving to the center of the screen ?

Code: Select all

RButton::
MouseClick, Right, 959,539, 1, 50, D
GetKeyState, state, RButton

Loop 
{
	if !GetKeyState("state", "P")  ; The key has been released, so break out of the loop.
 	break	
}
 
MouseClick, Right,,,,, U 	
return
If for instance you would only want the code to trigger while notepad is open, you could do something like this:

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

#IfWinActive, ahk_exe notepad.exe		; <<<<< Only trigger the code when notepad is active. Change this to your programs exe file

RButton::
MouseClick, Right, 959,539, 1, 50, D
GetKeyState, state, RButton

Loop 
{
	if !GetKeyState("state", "P")  ; The key has been released, so break out of the loop.
 	break	
}
 
MouseClick, Right,,,,, U 		; release the button
return

Laszlo
Posts: 7
Joined: 25 May 2022, 02:48

Re: PLEASE HELP with mouse cursor move and pressing down

Post by Laszlo » 25 May 2022, 04:10

what i wanna do is:

when i click the right mouse button and keep pressing it, i'd like that happen 'as the cursor is first automatically moved to the center of the screen'.
and when i release the right button, pressing down action also stops.

basically everything is same except the cursor must be at certain location.

Can you Please make such code?

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Please help with mouse cursor move and pressing down

Post by WalkerOfTheDay » 25 May 2022, 06:48

Still not completely sure if this is what you mean:

I would recommend adding a CTRL to the hotkey so you keep the original functionality of the right button. Like so:

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

^RButton::			; press CTRL+RButton to trigger the script
click, down, right 		; hold down the right mouse button
mousemove, 959, 539, 1	; move to the center of the screen
click, up, right		; release the right button
return

Laszlo
Posts: 7
Joined: 25 May 2022, 02:48

Re: Please help with mouse cursor move and pressing down

Post by Laszlo » 25 May 2022, 07:16

sry about the poor explanation.

I'm playing a game called "VRising" atm. in this game, you can rotate a screen while holding down the right mouse button. and if you attack while you are holding down the right mouse button, your character attacks into the direction of where your mouse cursor was when the right mouse button was pressed down, not into the direction of the north of the screen. what i wanna do is, always attacking to northern direction (of the screen) while pressing down the right mouse button, no matter wherever the mouse cursor was positioned when the right mouse button was pressed down. and, it seems, the only way to make that possible, is moving your mouse cursor automatically to a certain northen position of the screen before pressing down and holding down the right mouse button.

hope this helps... PLEASE HELP ME

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Please help with mouse cursor move and pressing down  Topic is solved

Post by WalkerOfTheDay » 25 May 2022, 07:54

Okay so if I understand correctly. You first want move your mouse to 959, 539.
Then hold down the right mouse button ? And let it go when you physically release the right mouse button ?

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

RButton::			; press RButton to trigger the script
mousemove, 959, 539, 1	; move to the center of the screen
click, down, right 		; hold down the right mouse button
Loop
{
	if !GetKeyState("RButton", "P")
	{
		click, up, right		; release the right button
		break
	}
}
Last edited by WalkerOfTheDay on 25 May 2022, 08:52, edited 2 times in total.

Laszlo
Posts: 7
Joined: 25 May 2022, 02:48

Re: Please help with mouse cursor move and pressing down

Post by Laszlo » 25 May 2022, 08:43

WOW................ IT WORKS PERFECTLY!

/Salute to your supremacy, kindness, help!
you are my life-savior.

Thank You so much!!! <3
I LOVE YOU.

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Please help with mouse cursor move and pressing down

Post by WalkerOfTheDay » 25 May 2022, 08:53

Glad I could help.

Laszlo
Posts: 7
Joined: 25 May 2022, 02:48

Re: Please help with mouse cursor move and pressing down

Post by Laszlo » 25 May 2022, 11:32

Sir,

is there a way to move the mouse cursor faster?
what's the fastest way to move the cursor?
I want it to move almost as it teleported, is that possible?

as when i click the right mouse button while moving the cursor fast, sometimes the cursor doesn't get moved/fixed at the intended coordinate.

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Please help with mouse cursor move and pressing down

Post by WalkerOfTheDay » 25 May 2022, 15:19

You can try to replace the 1 in the mousemove command to 0 but I doubt if that fixes it.

Perhaps someone with more advanced knowledge like @boiler can help out.

User avatar
boiler
Posts: 16772
Joined: 21 Dec 2014, 02:44

Re: Please help with mouse cursor move and pressing down

Post by boiler » 25 May 2022, 15:30

I would have also suggested changing the speed to 0, which is basically instantaneous.

Laszlo
Posts: 7
Joined: 25 May 2022, 02:48

Re: Please help with mouse cursor move and pressing down

Post by Laszlo » 25 May 2022, 22:43

i changed to:

mousemove, 959.5, 400, 0

however, still if i press down the right mouse button while moving around the mouse cursor fast, many times the cursor ends up not at the center. which ie werid to me as 0 speed should mean instantaneus.
weird, wierd...

maybe this is a bug or something physically not mendable???

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Please help with mouse cursor move and pressing down

Post by WalkerOfTheDay » 30 May 2022, 07:10

You could try BlockInput to prevent mouse movements.

Run this as administrator (important !) It should block your physical mousemoves.

Code: Select all

#Persistent

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

RButton::			; press RButton to trigger the script
BlockInput MouseMove
mousemove, 959, 539, 0	; move to the center of the screen
BlockInput MouseMoveOff
click, down, right 		; hold down the right mouse button


Loop
{
	if !GetKeyState("RButton", "P")
	{
		click, up, right		; release the right button
		break
	}
}

return

ESC::
MsgBox, Bye
ExitApp

Post Reply

Return to “Gaming Help (v1)”