Record mouse position script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
gyrosav
Posts: 81
Joined: 30 Dec 2020, 02:48

Record mouse position script

Post by gyrosav » 05 Feb 2023, 05:59

Hello, I am trying to create a record mouse location script.

I'd like this script to have a simple gui so that I know when it is toggled on or off.

1. Pressing F5 will toggle on the script and record the mouse cursor position. This toggle will also change how my mouse works. Every left click will now jump my mouse to the recorded mouse cursor position and right click on that spot. Once the right click has been sent, then the mouse cursor should jump back to the middle of the screen.

Pressing F5 again will toggle off this script so that my mouse behaves normally.


I know this is a long shot, but if something like this is possible or anything close to it, I'd greatly appreciate it. Thank you kindly~

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: Record mouse position script  Topic is solved

Post by mikeyww » 05 Feb 2023, 09:40

Code: Select all

#Requires AutoHotkey v2.0
gui1 := Gui('+AlwaysOnTop', 'Recording'), gui1.SetFont('s14')
txt := gui1.AddText('w200 Center')
gui1.Show('x1500 y50'), guiToggle(on := False)
cx := A_ScreenWidth / 2, cy := A_ScreenHeight / 2

F5:: {
 Global on, x, y
 CoordMode 'Mouse'
 guiToggle(on := !on), MouseGetPos(&x, &y)
}

#HotIf on
LButton:: {
 CoordMode 'Mouse'
 MouseClick('R', x, y), MouseMove(cx, cy)
 SoundBeep 900
}
#HotIf

guiToggle(trueFalse) {
 If trueFalse
      gui1.BackColor := 'FFFF9E', txt.Value := 'ON' , SoundBeep(1500)
 Else gui1.BackColor := 'FF8E8E', txt.Value := 'OFF', SoundBeep(1000)
}

gyrosav
Posts: 81
Joined: 30 Dec 2020, 02:48

Re: Record mouse position script

Post by gyrosav » 05 Feb 2023, 20:31

@mikeyww

Thank you mikey. You're a genius. I can't believe this works.

gyrosav
Posts: 81
Joined: 30 Dec 2020, 02:48

Re: Record mouse position script

Post by gyrosav » 05 Feb 2023, 20:56

@mikeyww

Can you help me with a slightly different version of this?

Instead of a toggle, can I have pressing 'y' show a little box next to my cursor that says "left click" and when I left click it records the mouse position?

And only when I press control+v, the mouse will jump to the recorded mouse position and immediately right click and then jump the mouse cursor back to the middle. Or if possible, have the mouse jump back to the most recent left click right after the right click.

The toggle gui is not needed for this but the small text box that primes the left click for the record mouse position next to the cursor would be fantastic. I would greatly appreciate your help once more. Thank you for making me realize how powerful AHK can be.

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: Record mouse position script

Post by mikeyww » 05 Feb 2023, 21:00

I'm going to leave these changes to you, as my time is going to be very limited in the coming week. Good luck! Perhaps it is a good way to learn some AutoHotkey.

gyrosav
Posts: 81
Joined: 30 Dec 2020, 02:48

Re: Record mouse position script

Post by gyrosav » 05 Feb 2023, 21:11

@mikeyww

I understand thank you! I will give it a shot!

Post Reply

Return to “Gaming Help (v1)”