Remember spots to send clicks to Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ztoddw
Posts: 5
Joined: 31 Jan 2015, 23:47

Remember spots to send clicks to

07 Jan 2022, 13:25

This seemed to me like it should be a pretty common and useful thing to a lot of people, so I'd be surprised if no one has a script already to do this...

I'm looking for a script to be able to assign certain spots on my screen, and assign a different hot key combination to each spot, to be able to have a click simulated on that spot when I press that hot key combination. I imagine I would click a button to tell the script I'm ready to assign a new spot, then I'll click on that new spot, then press the key or key combination I want to use as the trigger for it. Then every time I press that key combination after that, it will generate a click on that spot.

I looked a little at Pulover’s Macro Creator at https://www.macrocreator.com/ but that seems to just create a script, and doesn't automatically set up hotkeys for the places I click.

I want to be able to set up multiple places on screen to send clicks to by pressing different key combos.
User avatar
mikeyww
Posts: 27369
Joined: 09 Sep 2014, 18:38

Re: Remember spots to send clicks to  Topic is solved

07 Jan 2022, 14:36

You're right. What did you find in your forum search?

Code: Select all

map := {}, width := 250
Gui, Font, s10
Gui, Add, Text  , Center   w%width% vcoord
Gui, Add, Text  , xm                       , Hotkey:
Gui, Add, Hotkey, x+m yp-3 w190     vhk
Gui, Add, Button, xm       w%width% Default, OK

F3::
CoordMode, Mouse
MouseGetPos, x, y
GuiControl,, coord, (%x%,%y%)
Gui, Show,, Clicks
Return

ButtonOK:
Gui, Submit
map[hk, "x"] := x, map[hk, "y"] := y
Hotkey, %hk%, Clik, On
Return

Clik:
CoordMode, Mouse
MouseClick,, map[A_ThisHotkey].x, map[A_ThisHotkey].y
Return

GuiEscape:
GuiClose:
Gui, Hide
Return
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Remember spots to send clicks to

07 Jan 2022, 15:06

@mikeyww

Didn't know you could skip declaring the nested object like this.

Code: Select all

Map := {}
Map[ hk , "x" ] := SomeValue
as opposed to something like this.


Code: Select all

Map := {}
Map[ hk ] := { X: SomeValue }
Thanks for sharing :thumbup:
User avatar
mikeyww
Posts: 27369
Joined: 09 Sep 2014, 18:38

Re: Remember spots to send clicks to

07 Jan 2022, 15:11

You are welcome. Reference: https://www.autohotkey.com/docs/Objects.htm#Usage_Arrays_of_Arrays
table[x][y] := content ; A
table[x, y] := content ; B

If table[x] does not exist, A fails whereas B automatically creates an object and stores it in table[x].
ztoddw
Posts: 5
Joined: 31 Jan 2015, 23:47

Re: Remember spots to send clicks to

08 Jan 2022, 02:53

mikeyww wrote:
07 Jan 2022, 14:36
You're right. What did you find in your forum search?

Code: Select all

map := {}, width := 250
Gui, Font, s10
Gui, Add, Text  , Center   w%width% vcoord
Gui, Add, Text  , xm                       , Hotkey:
Gui, Add, Hotkey, x+m yp-3 w190     vhk
Gui, Add, Button, xm       w%width% Default, OK

F3::
CoordMode, Mouse
MouseGetPos, x, y
GuiControl,, coord, (%x%,%y%)
Gui, Show,, Clicks
Return

ButtonOK:
Gui, Submit
map[hk, "x"] := x, map[hk, "y"] := y
Hotkey, %hk%, Clik, On
Return

Clik:
CoordMode, Mouse
MouseClick,, map[A_ThisHotkey].x, map[A_ThisHotkey].y
Return

GuiEscape:
GuiClose:
Gui, Hide
Return
Awesome sauce. I didn't find what I was looking for when I searched before. But this looks like what I was looking for. Kudos.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Mateusz53 and 151 guests