Can I get some help with an AHK script that stores mouse positions?

Ask gaming related questions
acnl
Posts: 95
Joined: 25 Nov 2017, 09:04

Can I get some help with an AHK script that stores mouse positions?

11 Apr 2024, 05:09

I need help on a simple ahk script that stores two different mouse cursor positions and then presses left click on those positions in a specific manner.

1. When I press control+a, it will store my current mouse cursor position as position1.
2. When I press control+s, it will store my current mouse cursor position as position2.
3. Every 4-5 minutes, the script will move my mouse cursor to p1 and press left click. It will then wait 30 seconds from that left click and then move my mouse to p2 and press left click. Then the script will reset and wait for the next 4-5 minutes. It will keep looping in this manner.
4. The script should choose a random time between 4-5 minutes.
5. The script/timer begins when I press control+d. Pressing control+d also resets the timer.

Could you please create this script for me? Thank you!
User avatar
mikeyww
Posts: 27131
Joined: 09 Sep 2014, 18:38

Re: Can I get some help with an AHK script that stores mouse positions?

11 Apr 2024, 08:19

Code: Select all

#Requires AutoHotkey v2.0
pos := Map()

^a::store(1)
^s::store(2)
^d:: {
 Global n := 2
 go(), SoundBeep(2500)
}

store(n) {  ; Store mouse position
 CoordMode('Mouse'), MouseGetPos(&x, &y)
 pos[n] := [x, y]
 SoundBeep 500 + 500 * n
}

go() {      ; Click and start timer
 Static wait := [[30, 30], [240, 300]]
 Global n
 CoordMode 'Mouse'
 If pos.Count
  If pos.Has(n := 3 - n)
   Click(pos[n]*), SetTimer(go, -1000 * Random(wait[n]*))
  Else go
}

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests