Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Searching Elegant Solution For Getting Mouse Coordinates

$
0
0
Dear fellow AutoIt users

I am currently working on my first script because of personal interest, the script itself will most likely be useless and 'use for fun'. However I am currently stuck and Google did not really help much... Please help me!

The goal of the script is to execute short tasks including mouse movement.

Here is an abstract code prototype to help understanding of the problem, do not use it as guideline:
[ autoit ]      
HotKeySet('{LCTRL}+K', 'CoordGet') ;hotkeys for tasks HotkeySet('{ESC}', 'Terminate') Func CoordGet() ;grabbing coordinates using: $MousePos=MouseGetPos() CoordX[0] = MousePos[0], CoordY[0] = MousePos[0] EndFunc Func example() MouseMove (CoordX[0], CoordY[0], 0) EndFunc Func Terminate() Exit EndFunc
Problem:
I want to implement a function CoordGet that saves the current coordinates of my mouse into an array so I can use them later

My Ideas:
I already thought about different ways to implement the function:
- using Do MouseGetPos Until (isn't this resource heavy since it grabs many unneeded coordinates)
- using nested while loops with a toggle for the whole function (makes it hotkey and code heavy)
- just writing the code to grab 2-3 coordinates when the script is started and using a hotkey as signal to get the current coordinates (really inflexible, cannot reassign coordinates, I don't know how to let the script wait for the specific hotkey input)

Question:
Can you recommend and show elegant and simple solutions for a function executed when pressing a hotkey that grabs hotkeys and enters them into arrays until the function is ended? Alternatively less efficient and flexible solutions would work as well if they are easier to implement.


Thank you a lot for every helpful reply!

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>