Sign in to follow this  
Followers 0
Magix

Cycle array -MouseGetPos

5 posts in this topic

Hello, what I am trying to do is a toggle key to cycle through x amount of variables storing the mouse posistions each time the toggle is pressed. For example "H" is the toggle key, this is what would happen when "H" is pressed. "H DOWN" > MouseGetPos > store pos to $array[0] > switch to $array[1] ready for next key press.

Hope that makes sense, anyway help is appreciated, thanks.

Share this post


Link to post
Share on other sites



Magix,

First, welcome to the AutoIt forums. :graduated:

HotKeySet will let you use a suitable key combination to toggle your mouse position collection code.

Do you have an idea of how many positions you are going to collect? If so, you can dimension your array as you declare it - if not, then ReDim would be another good command to study. :D

Give it a go yourself - you know where we are if you run into difficulties. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for the reply and the welcome :graduated:

I am trying to store 4 posistions in total, if I am honest I don't know alot and even less about arrays.

This is what I have so far;

Global $TogGetPos= 0
Global $GetPos[5]

$TogGetPos = HotKeySet("6F", "ToggleGetPos")

Func ToggleGetPos()
    $TogGetPos = $TogGetPos + 1
    If $TogGetPos = 1 Then
        $GetPos[0] = MouseGetPos()
        $TogGetPos = $TogGetPos + 1
    EndIf
    If $TogGetPos = 2 Then
        $GetPos = MouseGetPos()
        $TogGetPos = $TogGetPos + 1
    EndIf
    If $TogGetPos = 3 Then
        $GetPos = MouseGetPos()
        $TogGetPos = $TogGetPos + 1
    EndIf
    If $TogGetPos = 4 Then
        $GetPos = MouseGetPos()
        $TogGetPos = $TogGetPos + 1
    EndIf

EndFunc   ;==>ToggleGetPos
Edited by Magix

Share this post


Link to post
Share on other sites

Magix,

if I am honest I don't know alot

It shows! :D But do not worry - we all started at that point. :graduated:

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading.

I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. :D

Here is some working code to do what you want - try and understand what is going on:

#include <Array.au3> ; Only to display the result

; Declare array and set count to 0
Global $aStorePos[5][2] = [[0, 0]]

; Declare HotKey
HotKeySet("h", "ToggleGetPos")

While 1
    Sleep(100)
WEnd

Func ToggleGetPos()

    ; Increase count
    $aStorePos[0][0] += 1
    $aMousePos = MouseGetPos()
    $aStorePos[$aStorePos[0][0]][0] = $aMousePos[0]
    $aStorePos[$aStorePos[0][0]][1] = $aMousePos[1]

    ; And show how the array is filled
    _ArrayDisplay($aStorePos)
    ; And exit when all 4 points collected
    If $aStorePos[0][0] = 4 Then Exit

EndFunc   ;==>ToggleGetPos

Ask if you have any questions AFTER you have had a good read of the Help file for each of the commands I used and read the Arrays tutorial in the Wiki. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Haha, much appreciated Melba23, I will certainly read through all of what you have suggested, but at first glance the arrays just confuse the hell out of me lol. I will however, plod on and try to make sense of it. Thanks again for your time and help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0