Jump to content

PixelChecksum using MouseGetPos coords


Recommended Posts

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

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 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

  • Moderators

blckpythn,

Welcome to the AutoIt forum. :(

This will seem a lot of comment - do not get discouraged! :D

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. B) 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. :)

M23

Edit: Typnig - and hello to the flightless one!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

blckpythn,

We all do from time to time! :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...