Problem with retrieving value from associative array Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Problem with retrieving value from associative array

18 Nov 2018, 11:43

Hello guys,

I created several associative arrays (let's call 'em AA) which have stored 3 different values.
X coordinate, y coordinate, click amount.

It's possible that my mouse cursor gets moved to the coordinates, but the clicking does not work.
That's the script (I also tried different variations):

Code: Select all

F11::
objectA := {x:532, y:368, r:1}, objectB := {x:64, y:68, r:2}, objectC := {x:96, y:68, r:0} ; List of associative arrays
MouseMove, objectA.x, objectA.y, 0 ; Move mouse to x, y coordinates of objectA (fastest speed)
Send {rbutton objectA.r} ; Click rbutton as often as declared in objectA - DOES NOT WORK !
;Send {rbutton %objectA.r%} ; Click rbutton as often as declared in objectA - DOES NOT WORK - "ILLEGAL CHARACTER"
;Send {rbutton %objectA%.r} ; Click rbutton as often as declared in objectA - DOES NOT WORK !
;Send {rbutton objectA.%r%} ; Click rbutton as often as declared in objectA - DOES NOT WORK !
return
This, for example, works perfectly:

Code: Select all

^F11:: ; Ctrl+F11
a = 1 ; amount = 1
Send {rbutton %a%} ; Click rbutton as often as declared in a
return
Do you know how to make it work in the first script?
Or do I need another support variable which retrieves the AA value of r?

P.S.
I also made

Code: Select all

objectA := {f:10, x:532, y:368, r:1}
and released the mouse movement still worked - so the amount of values doesn't seem to be the reason.

Best regards and thanks for any help!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Problem with retrieving value from associative array  Topic is solved

18 Nov 2018, 12:03

Code: Select all

objectA := {x:532, y:368, r:1}
MouseMove, objectA.x, objectA.y, 0 
Send % "{rbutton " objectA.r "}"
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Problem with retrieving value from associative array

18 Nov 2018, 12:25

That works, thanks!
Impossible to find that out - at least for me.

Could it be written also different?
Because I typically always use the %variable% instead of % variable.
I prefer the beginner version - Is easier for me. :P

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Problem with retrieving value from associative array

18 Nov 2018, 12:36

no, for that to work ull have to store the result in a separate, temp variable first

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], Rohwedder, ulysim and 362 guests