Magix Posted November 17, 2010 Posted November 17, 2010 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.
Moderators Melba23 Posted November 17, 2010 Moderators Posted November 17, 2010 Magix,First, welcome to the AutoIt forums. 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. 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Magix Posted November 17, 2010 Author Posted November 17, 2010 (edited) Thanks for the reply and the welcome 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 November 17, 2010 by Magix
Moderators Melba23 Posted November 17, 2010 Moderators Posted November 17, 2010 Magix, if I am honest I don't know alotIt shows! But do not worry - we all started at that point. 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. 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Magix Posted November 17, 2010 Author Posted November 17, 2010 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now