blckpythn Posted April 16, 2010 Share Posted April 16, 2010 Hello AutoIters, I am trying to write a short script that will grab the mouse position, grab a pixel checksum around it, and monitor it for changes. Here is what I have so far Opt("MouseCoordMode", 0) Opt("MustDeclareVars", 0) Global $mousepos = MouseGetPos() Global $pixelpos[1][2][3][4] ;~ $pixelpos[1] = $mousepos[0] - 5 ;left ;~ $pixelpos[2] = $mousepos[1] + 5 ;top ;~ $pixelpos[3] = $mousepos[0] + 5 ;right ;~ $pixelpos[4] = $mousepos[1] - 5 ;bottom ;~ $pixelcheck = PixelChecksum($mousepos[0] - 5, $mousepos[1] + 5, $mousepos[0] + 5, $mousepos[1] - 5) MsgBox(0, "Pixel Checksum range", "Pixel Checksum range is" & $pixelpos) And I keep getting errors such as "array variable has incorrect number of subscripts or subscript dimension range exceeded.:" Any clues on how to fix this? Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 16, 2010 Share Posted April 16, 2010 (edited) You need to look again at how arrays are declared and used. A four element one-dimensional array is declared this way: Global $pixelpos[4] And the index is zero-based, so the elements are $pixelpos[0] thru $pixelpos[3]. Edit: Oops, forgot Global keyword. Edited April 16, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 (edited) blckpythn,Welcome to the AutoIt forum. This will seem a lot of comment - do not get discouraged! 1. If you change the MouseCoordMode, you also need to change the PixelCoordMode or the 2 will not match and you will not be looking at the pixels you think you are. 2. The default value for the MustDeclareVars mode is 0, so there is no need to declare it.3. You need to read the array tutorial in the Wiki here. You have declared $pixelpos as a 4D array - so you would need to have 4 indices each time you use it - no wonder youwere getting errors. What you need is a 4-element 1D array - which has elements 0-3, not 1-4 by the way. 4. You were trying to display the $pixelpos array in the MsgBox, not the $pixelcheck checksum - so nothing would ever show.Take a look at this:Opt("MouseCoordMode", 0) Opt("PixelCoordMode", 0) ;Opt("MustDeclareVars", 0) Global $mousepos = MouseGetPos() Global $pixelpos[4] $pixelpos[0] = $mousepos[0] - 5 ;left $pixelpos[1] = $mousepos[1] + 5 ;top $pixelpos[2] = $mousepos[0] + 5 ;right $pixelpos[3] = $mousepos[1] - 5 ;bottom $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) MsgBox(0, "Pixel Checksum range", "Pixel Checksum range is" & $pixelcheck)Please ask if anything is unclear. M23Edit: Typnig - and hello to the flightless one! Edited April 16, 2010 by Melba23 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 Link to comment Share on other sites More sharing options...
blckpythn Posted April 16, 2010 Author Share Posted April 16, 2010 Wow, very informative. I realize now what I did wrong, and thank you for the code Melba23. One more question. Occasionaly when I type in Scite it will overlap on text there instead of inserting it between the characters that my cursor is in. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 blckpythn,Nothing to do with SciTE. You have probably pressed your Insert key inadvertantly. If I am in Insert mode SciTE gives me an underscore ( _ ) as a cursor rather than the usual vertical bar ( | ) - try it yourself and see if it does the same for you. 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 Link to comment Share on other sites More sharing options...
blckpythn Posted April 16, 2010 Author Share Posted April 16, 2010 Yep, thanks, I feel dumb Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 blckpythn, We all do from time to time! 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 Link to comment Share on other sites More sharing options...
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