Jump to content
schoel

Pixel Checksum Automation

Recommended Posts

schoel

This a script for making PixelChecksums easier, with skeleton code generation. I'm quite sure many people have done this, here is my contribution though.

Use Ctrl + Shift + x to select a coordinate and Ctrl + Shift + c to make a PixelChecksum of selected coordinates. Ctrl + Shift + z clears the text box.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("^+x", "getMousePos")
HotKeySet("^+c", "getPixelChecksum")
HotKeySet("^+z", "clearEdit")

$winHeight = 600
$winWidth = 430
$mainWindow = GUICreate("Pixel Checksum Automation", $winWidth, $winHeight, @DesktopWidth - $winWidth - 50)
GUISetState()
WinSetOnTop("Pixel Checksum Automation", "", 1)

$fileMenu = GUICtrlCreateMenu("&File")
$fileOpen = GUICtrlCreateMenuItem("Open...", $fileMenu)
$fileSave = GUICtrlCreateMenuItem("Save...", $fileMenu)
$fileExit = GUICtrlCreateMenuItem("Exit", $fileMenu)

$settingsMenu = GUICtrlCreateMenu("&Settings")
$settingsOnTop = GUICtrlCreateMenuItem("Always on top", $settingsMenu)
GUICtrlSetState(-1, $GUI_CHECKED)

$helpMenu = GUICtrlCreateMenu("&Help")
$helpHelp = GUICtrlCreateMenuItem("Help", $helpMenu)

GUICtrlCreateLabel("Mouse Position", 5, 5)
GUICtrlCreateLabel("X:", 5, 20)
GUICtrlCreateLabel("Y:", 55, 20)
$xValue = GUICtrlCreateLabel("", 20, 20, 30, 15)
$yValue = GUICtrlCreateLabel("", 70, 20, 30, 15)

GUICtrlCreateLabel("While loop:", 5, 35)
$whileEquals = GUICtrlCreateCheckbox("Equals", 5, 50)
$whileNotEquals = GUICtrlCreateCheckbox("Not Equals", 70, 50)
GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel("Do loop:", 190, 35)
$doEquals = GUICtrlCreateCheckbox("Equals", 190, 50)
$doNotEquals = GUICtrlCreateCheckbox("Not Equals", 255, 50)

GUICtrlCreateLabel("If statement:", 5, 70)
$ifEquals = GUICtrlCreateCheckbox("Equals", 5, 85)
$ifNotEquals = GUICtrlCreateCheckbox("Not Equals", 70, 85)

GUICtrlCreateLabel("Combined with Global Const:", 190, 70)
$yes = GUICtrlCreateCheckbox("Yes", 190, 85)
GUICtrlCreateLabel("Variable name:", 230, 89)
$globalConstInput = GUICtrlCreateInput("", 303, 85, 100, 20)

GUICtrlCreateLabel("Upper left coordinates:", 5, 105)
GUICtrlCreateLabel("Lower right coordinates:", 5, 120)

$upperLeft = GUICtrlCreateLabel("", 125, 105, 60)
$lowerRight = GUICtrlCreateLabel("", 125, 120, 60)
$clearCoordinates = GUICtrlCreateButton("Clear coordinates", 190, 108) 
$currentCoordinate = "upper_left"

$edit = GUICtrlCreateEdit("", 5, 140, $winWidth - 10, 435)

Dim $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $fileExit
            ExitLoop
        Case $fileOpen
            $openFile = FileOpenDialog("Open file", @ScriptDir, "Text files (*.txt)", 3)
            $openFileHandle = FileOpen($openFile, 0)
            $text = FileRead($openFileHandle)
            GUICtrlSetData($edit, $text)
            FileClose($openFileHandle)
        Case $fileSave
            $text = GUICtrlRead($edit)
            $saveFile = FileSaveDialog("Save file", @ScriptDir, "Text files (*.txt)", 18)
            If StringCompare(StringRight($saveFile, 4), ".txt", 0) <> 0 Then
                $saveFile = $saveFile & ".txt"
            EndIf
            $saveFileHandle = FileOpen($saveFile, 2)
            FileWrite($saveFileHandle, $text)
            FileClose($saveFileHandle)
        Case $settingsOnTop
            If BitAND(GUICtrlRead($settingsOnTop), $GUI_CHECKED) = $GUI_CHECKED Then
                WinSetOnTop("Pixel Checksum Automation", "", 0)
                GUICtrlSetState($settingsOnTop, $GUI_UNCHECKED)
            Else
                WinSetOnTop("Pixel Checksum Automation", "", 1)
                GUICtrlSetState($settingsOnTop, $GUI_CHECKED)
            EndIf
        Case $helpHelp
            MsgBox(64, "Help", "Use Shift + Control + x to select coordinates, Shift + Control + c to do a pixel checksum of the selected coordinates and Shift + Control + z to clear the edit box")
        Case $clearCoordinates
            clearCoordinates()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
        
    $array = MouseGetPos()
    GUICtrlSetData($xValue, $array[0])
    GUICtrlSetData($yValue, $array[1])
    Sleep(30)
WEnd
GUIDelete()

Func getMousePos()
    $array = MouseGetPos()
    If $currentCoordinate = "upper_left" Then
        GUICtrlSetData($upperLeft, $array[0] & ", " & $array[1])
        $x1 = $array[0]
        $y1 = $array[1]
        $currentCoordinate = "lower_right"
    ElseIf $currentCoordinate = "lower_right" Then
        GUICtrlSetData($lowerRight, $array[0] & ", " & $array[1])
        $x2 = $array[0]
        $y2 = $array[1]
        $currentCoordinate = "upper_left"
    EndIf   
EndFunc

Func getPixelChecksum()
    If $x1 > $x2 Or $y1 > $y2 Then
        WinSetOnTop("Pixel Checksum Automation", "", 0)
        MsgBox(48, "Bad coordinates", "You have entered bad coordinates! The upper left corner coordinates must be above and to the left of the lower right coordinates.")
        If BitAND(GUICtrlRead($settingsOnTop), $GUI_CHECKED) = $GUI_CHECKED Then
            WinSetOnTop("Pixel Checksum Automation", "", 1)
        EndIf
        clearCoordinates()
    Else
        $checksum = PixelChecksum($x1, $y1, $x2, $y2)   
        
        $text = GUICtrlRead($edit)
        $varName = GUICtrlRead($globalConstInput)
        If BitAND(GUICtrlRead($whileEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "While(PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") = " & $checksum & ")" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "While(PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) = $" & $varName & "Checksum)" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($whileNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "While(PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") <> " & $checksum & ")" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "While(PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) <> $" & $varName & "Checksum)" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($doEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") = " & $checksum & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) = $" & $varName & "Checksum" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($doNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") <> " & $checksum & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) <> $" & $varName & "Checksum" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($ifEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "If PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") = " & $checksum & " Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "If PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) = $" & $varName & "Checksum Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($ifNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "If PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") <> " & $checksum & " Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "If PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) <> $" & $varName & "Checksum Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
    EndIf
EndFunc

Func clearCoordinates()
    GUICtrlSetData($upperLeft, "")
    GUICtrlSetData($lowerRight, "")
    $currentCoordinate = "upper_left"
    $x1 = 0
    $y1 = 0
    $x2 = 0
    $y2 = 0
EndFunc

Func clearEdit()
    GUICtrlSetData($edit, "")
EndFunc
Edited by schoel
  • Like 1

Share this post


Link to post
Share on other sites
Skizmata

Nice work, this is super helpful for seting up some things I do oftem. Thanks.


AutoIt changed my life.

Share this post


Link to post
Share on other sites
schoel

Thanks! That's why I made it in the first place ^_^

Share this post


Link to post
Share on other sites
Euth

Thanks! That's why I made it in the first place :)

schoel,

I stumbled upon this script when researching the way PixelChecksum works and how to use it. I have since gained a lot more understanding of how to implement them into my projects. I started to create a similar script to save myself time in generating them, but then remembered you've already done the hard for me.

I am so glad I found this post again. It would have taken me days to write something comparable. Thank you so much for your contribution.

Share this post


Link to post
Share on other sites
Euth

For what it's worth, I added the ability to change the Coord Mode. I needed "client area" for my current project and decided I'd try my hand at the GuiCtrl functions, rather than hardcoding the setting into the script. It makes the script that much more valuable to me. I have no experience with the GuiCtrl functions yet, so go easy on me if it looks hacky.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("^+x", "getMousePos")
HotKeySet("^+c", "getPixelChecksum")
HotKeySet("^+z", "clearEdit")

$winHeight = 600
$winWidth = 430
$mainWindow = GUICreate("Pixel Checksum Automation", $winWidth, $winHeight, @DesktopWidth - $winWidth - 50)
GUISetState()
WinSetOnTop("Pixel Checksum Automation", "", 1)

$fileMenu = GUICtrlCreateMenu("&File")
$fileOpen = GUICtrlCreateMenuItem("Open...", $fileMenu)
$fileSave = GUICtrlCreateMenuItem("Save...", $fileMenu)
$fileExit = GUICtrlCreateMenuItem("Exit", $fileMenu)

$settingsMenu = GUICtrlCreateMenu("&Settings")
$settingsOnTop = GUICtrlCreateMenuItem("Always on top", $settingsMenu)
GUICtrlSetState(-1, $GUI_CHECKED)
$settingsCoordMode = GUICtrlCreateMenu("Coord Mode", $settingsMenu)
$coordModeScreen = GUICtrlCreateMenuItem("Screen", $settingsCoordMode)
GUICtrlSetState(-1, $GUI_CHECKED)
$coordModeWindow = GUICtrlCreateMenuItem("Window", $settingsCoordMode)
$coordModeClient = GUICtrlCreateMenuItem("Client", $settingsCoordMode)


$helpMenu = GUICtrlCreateMenu("&Help")
$helpHelp = GUICtrlCreateMenuItem("Help", $helpMenu)

GUICtrlCreateLabel("Mouse Position", 5, 5)
GUICtrlCreateLabel("X:", 5, 20)
GUICtrlCreateLabel("Y:", 55, 20)
$xValue = GUICtrlCreateLabel("", 20, 20, 30, 15)
$yValue = GUICtrlCreateLabel("", 70, 20, 30, 15)

GUICtrlCreateLabel("While loop:", 5, 35)
$whileEquals = GUICtrlCreateCheckbox("Equals", 5, 50)
$whileNotEquals = GUICtrlCreateCheckbox("Not Equals", 70, 50)
GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel("Do loop:", 190, 35)
$doEquals = GUICtrlCreateCheckbox("Equals", 190, 50)
$doNotEquals = GUICtrlCreateCheckbox("Not Equals", 255, 50)

GUICtrlCreateLabel("If statement:", 5, 70)
$ifEquals = GUICtrlCreateCheckbox("Equals", 5, 85)
$ifNotEquals = GUICtrlCreateCheckbox("Not Equals", 70, 85)

GUICtrlCreateLabel("Combined with Global Const:", 190, 70)
$yes = GUICtrlCreateCheckbox("Yes", 190, 85)
GUICtrlCreateLabel("Variable name:", 230, 89)
$globalConstInput = GUICtrlCreateInput("", 303, 85, 100, 20)

GUICtrlCreateLabel("Upper left coordinates:", 5, 105)
GUICtrlCreateLabel("Lower right coordinates:", 5, 120)

$upperLeft = GUICtrlCreateLabel("", 125, 105, 60)
$lowerRight = GUICtrlCreateLabel("", 125, 120, 60)
$clearCoordinates = GUICtrlCreateButton("Clear coordinates", 190, 108)
$currentCoordinate = "upper_left"

$edit = GUICtrlCreateEdit("", 5, 140, $winWidth - 10, 435)

Dim $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $fileExit
            ExitLoop
        Case $coordModeWindow
            AutoItSetOption("PixelCoordMode",0)
            AutoItSetOption("MouseCoordMode",0)
            GUICtrlSetState($coordModeScreen, $GUI_UNCHECKED)
            GUICtrlSetState($coordModeWindow, $GUI_CHECKED)
            GUICtrlSetState($coordModeClient, $GUI_UNCHECKED)
        Case $coordModeScreen
            AutoItSetOption("PixelCoordMode",1)
            AutoItSetOption("MouseCoordMode",1)
            GUICtrlSetState($coordModeScreen, $GUI_CHECKED)
            GUICtrlSetState($coordModeWindow, $GUI_UNCHECKED)
            GUICtrlSetState($coordModeClient, $GUI_UNCHECKED)
        Case $coordModeClient
            AutoItSetOption("PixelCoordMode",2)
            AutoItSetOption("MouseCoordMode",2)
            GUICtrlSetState($coordModeScreen, $GUI_UNCHECKED)
            GUICtrlSetState($coordModeWindow, $GUI_UNCHECKED)
            GUICtrlSetState($coordModeClient, $GUI_CHECKED)
        Case $fileOpen
            $openFile = FileOpenDialog("Open file", @ScriptDir, "Text files (*.txt)", 3)
            $openFileHandle = FileOpen($openFile, 0)
            $text = FileRead($openFileHandle)
            GUICtrlSetData($edit, $text)
            FileClose($openFileHandle)
        Case $fileSave
            $text = GUICtrlRead($edit)
            $saveFile = FileSaveDialog("Save file", @ScriptDir, "Text files (*.txt)", 18)
            If StringCompare(StringRight($saveFile, 4), ".txt", 0) <> 0 Then
                $saveFile = $saveFile & ".txt"
            EndIf
            $saveFileHandle = FileOpen($saveFile, 2)
            FileWrite($saveFileHandle, $text)
            FileClose($saveFileHandle)
        Case $settingsOnTop
            If BitAND(GUICtrlRead($settingsOnTop), $GUI_CHECKED) = $GUI_CHECKED Then
                WinSetOnTop("Pixel Checksum Automation", "", 0)
                GUICtrlSetState($settingsOnTop, $GUI_UNCHECKED)
            Else
                WinSetOnTop("Pixel Checksum Automation", "", 1)
                GUICtrlSetState($settingsOnTop, $GUI_CHECKED)
            EndIf
        Case $helpHelp
            MsgBox(64, "Help", "Use Shift + Control + x to select coordinates, Shift + Control + c to do a pixel checksum of the selected coordinates and Shift + Control + z to clear the edit box")
        Case $clearCoordinates
            clearCoordinates()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
        
    $array = MouseGetPos()
    GUICtrlSetData($xValue, $array[0])
    GUICtrlSetData($yValue, $array[1])
    Sleep(30)
WEnd
GUIDelete()

Func getMousePos()
    $array = MouseGetPos()
    If $currentCoordinate = "upper_left" Then
        GUICtrlSetData($upperLeft, $array[0] & ", " & $array[1])
        $x1 = $array[0]
        $y1 = $array[1]
        $currentCoordinate = "lower_right"
    ElseIf $currentCoordinate = "lower_right" Then
        GUICtrlSetData($lowerRight, $array[0] & ", " & $array[1])
        $x2 = $array[0]
        $y2 = $array[1]
        $currentCoordinate = "upper_left"
    EndIf   
EndFunc

Func getPixelChecksum()
    If $x1 > $x2 Or $y1 > $y2 Then
        WinSetOnTop("Pixel Checksum Automation", "", 0)
        MsgBox(48, "Bad coordinates", "You have entered bad coordinates! The upper left corner coordinates must be above and to the left of the lower right coordinates.")
        If BitAND(GUICtrlRead($settingsOnTop), $GUI_CHECKED) = $GUI_CHECKED Then
            WinSetOnTop("Pixel Checksum Automation", "", 1)
        EndIf
        clearCoordinates()
    Else
        $checksum = PixelChecksum($x1, $y1, $x2, $y2)   
        
        $text = GUICtrlRead($edit)
        $varName = GUICtrlRead($globalConstInput)
        If BitAND(GUICtrlRead($whileEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "While(PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") = " & $checksum & ")" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "While(PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) = $" & $varName & "Checksum)" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($whileNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "While(PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") <> " & $checksum & ")" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "While(PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) <> $" & $varName & "Checksum)" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($doEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") = " & $checksum & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) = $" & $varName & "Checksum" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($doNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") <> " & $checksum & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "Do" & @CRLF & @CRLF & "Until PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) <> $" & $varName & "Checksum" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($ifEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "If PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") = " & $checksum & " Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "If PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) = $" & $varName & "Checksum Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
        $text = GUICtrlRead($edit)
        If BitAND(GUICtrlRead($ifNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            If BitAND(GUICtrlRead($yes), $GUI_CHECKED) <> $GUI_CHECKED Then
                GUICtrlSetData($edit, $text & "If PixelChecksum(" & $x1 & ","  & $y1 & "," & $x2 & "," & $y2 & ") <> " & $checksum & " Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
            Else
                GUICtrlSetData($edit, $text & "If PixelChecksum($" & $varName & "X1, $"  & $varName & "Y1, $" & $varName & "X2, $" & $varName & "Y2) <> $" & $varName & "Checksum Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X1 = " & $x1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "X2 = " & $x2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF)
                $text = GUICtrlRead($edit)
                GUICtrlSetData($edit, $text & "-------------------------------------------------------------------------------------" & @CRLF)
            EndIf
        EndIf
    EndIf
EndFunc

Func clearCoordinates()
    GUICtrlSetData($upperLeft, "")
    GUICtrlSetData($lowerRight, "")
    $currentCoordinate = "upper_left"
    $x1 = 0
    $y1 = 0
    $x2 = 0
    $y2 = 0
EndFunc

Func clearEdit()
    GUICtrlSetData($edit, "")
EndFunc
  • Like 1

Share this post


Link to post
Share on other sites
blk_panther

Hi,

I found the code so useful that I made some additions and while I was at it some improvements (see comments). Some things I did not found worthy of the comments:

  • To change the default CoordMode use setCoordMode([$mode=2]) with $mode = 0, 1 or 2 in line 48.
  • I put the GuiSetState() after all the gui code. It's a good practice I think.
  • I added a debug function (deb()) that wraps ConsoleWrite, feel free to use or delete it. (don't forget the constant $debug and every call to the function.)
  • I tried not to change the behavior/output/look of the script too much

Feel free to correct or report errors, make and share improvements or leave comments.

#cs http://www.autoitscript.com/forum/index.php?showtopic=93900
changed by blk_panther:
    -fixed half truncated coords by putting a space as text in $upperLeft + $lowerRight so autoheight calculation by GUICtrlCreateLabel is correct for later values
    -fixed flickering of Mouse Position by only drawing if the numbers changed
    -fixed MsgBox is under gui when always on top is on by making the MsgBox a child of the gui

    -added _findchecksum checkbox https://www.autoitscript.com/forum/topic/48333-find-pixelchecksum/
    -added check for empty coordinates
    -made CoordMode menu dry (don't repeat yourself) by putting it in a function with parameter
    -changed default CoordMode to 2 (Client)
    -changed Combined with Global Const to add them to the beginning and only once, even if more checkboxes are checked
        -shortened that code a "bit"
    -sorted functions alphabetically (better for collaboration)

todo:
    -position gui elements more logically (mouse position and coordinates together)
    -space gui elements more
    -ok + close button (ok = getPixelChecksum)
    -clear edit button?
#ce
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global Const $debug = 1


HotKeySet("^+x", "getMousePos")
HotKeySet("^+c", "getPixelChecksum")
HotKeySet("^+z", "clearEdit")

$winHeight = 600
$winWidth = 430
$mainWindow = GUICreate("Pixel Checksum Automation", $winWidth, $winHeight, @DesktopWidth - $winWidth - 110)
WinSetOnTop($mainWindow, "", 1)

$fileMenu = GUICtrlCreateMenu("&File")
$fileOpen = GUICtrlCreateMenuItem("Open...", $fileMenu)
$fileSave = GUICtrlCreateMenuItem("Save...", $fileMenu)
$fileExit = GUICtrlCreateMenuItem("Exit", $fileMenu)

$settingsMenu = GUICtrlCreateMenu("&Settings")
$settingsOnTop = GUICtrlCreateMenuItem("Always on top", $settingsMenu)
GUICtrlSetState(-1, $GUI_CHECKED)
$settingsCoordMode = GUICtrlCreateMenu("Coord Mode", $settingsMenu)
$coordModeScreen = GUICtrlCreateMenuItem("Screen", $settingsCoordMode)
$coordModeWindow = GUICtrlCreateMenuItem("Window", $settingsCoordMode)
$coordModeClient = GUICtrlCreateMenuItem("Client", $settingsCoordMode)
setCoordMode(2)


$helpMenu = GUICtrlCreateMenu("&Help")
$helpHelp = GUICtrlCreateMenuItem("Help", $helpMenu)

GUICtrlCreateLabel("Mouse Position", 5, 5)
GUICtrlCreateLabel("X:", 5, 20)
GUICtrlCreateLabel("Y:", 55, 20)
$xValue = GUICtrlCreateLabel("", 20, 20, 30, 15)
$yValue = GUICtrlCreateLabel("", 70, 20, 30, 15)

$findchecksum = GUICtrlCreateCheckbox("_findchecksum", 190, 15)
GUICtrlSetState(-1, $GUI_CHECKED)

GUICtrlCreateLabel("While loop:", 5, 35)
$whileEquals = GUICtrlCreateCheckbox("Equals", 5, 50)
$whileNotEquals = GUICtrlCreateCheckbox("Not Equals", 70, 50)

GUICtrlCreateLabel("Do loop:", 190, 35)
$doEquals = GUICtrlCreateCheckbox("Equals", 190, 50)
$doNotEquals = GUICtrlCreateCheckbox("Not Equals", 255, 50)

GUICtrlCreateLabel("If statement:", 5, 70)
$ifEquals = GUICtrlCreateCheckbox("Equals", 5, 85)
$ifNotEquals = GUICtrlCreateCheckbox("Not Equals", 70, 85)

GUICtrlCreateLabel("Combined with Global Const:", 190, 70)
$yes = GUICtrlCreateCheckbox("Yes", 190, 85)
GUICtrlCreateLabel("Variable name:", 230, 89)
$globalConstInput = GUICtrlCreateInput("", 303, 85, 100, 20)

GUICtrlCreateLabel("Upper left coordinates:", 5, 105)
GUICtrlCreateLabel("Lower right coordinates:", 5, 120)

$upperLeft = GUICtrlCreateLabel(" ", 125, 105, 60)
$lowerRight = GUICtrlCreateLabel(" ", 125, 120, 60)
$clearCoordinates = GUICtrlCreateButton("Clear coordinates", 190, 108)
$currentCoordinate = "upper_left"

$edit = GUICtrlCreateEdit("", 5, 140, $winWidth - 10, 435)
GUISetState()

Dim $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0, $mousePos[2]


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $fileExit
            Exit
        Case $coordModeWindow
            setCoordMode(0)
        Case $coordModeScreen
            setCoordMode(1)
        Case $coordModeClient
            setCoordMode(2)
        Case $fileOpen
            $openFile = FileOpenDialog("Open file", @ScriptDir, "Text files (*.txt)", 3)
            $openFileHandle = FileOpen($openFile, 0)
            $text = FileRead($openFileHandle)
            GUICtrlSetData($edit, $text)
            FileClose($openFileHandle)
        Case $fileSave
            $text = GUICtrlRead($edit)
            $saveFile = FileSaveDialog("Save file", @ScriptDir, "Text files (*.txt)", 18)
            If StringCompare(StringRight($saveFile, 4), ".txt", 0) <> 0 Then
                $saveFile = $saveFile & ".txt"
            EndIf
            $saveFileHandle = FileOpen($saveFile, 2)
            FileWrite($saveFileHandle, $text)
            FileClose($saveFileHandle)
        Case $settingsOnTop
            If BitAND(GUICtrlRead($settingsOnTop), $GUI_CHECKED) = $GUI_CHECKED Then
                WinSetOnTop($mainWindow, "", 0)
                GUICtrlSetState($settingsOnTop, $GUI_UNCHECKED)
            Else
                WinSetOnTop($mainWindow, "", 1)
                GUICtrlSetState($settingsOnTop, $GUI_CHECKED)
            EndIf
        Case $helpHelp
            MsgBox(64, "Help", "Use Shift + Control + x to set coordinates, Shift + Control + c to do a pixel checksum of the set coordinates and Shift + Control + z to clear the edit box", 0, $mainWindow)
        Case $clearCoordinates
            clearCoordinates()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    $array = MouseGetPos()
    If $array[0] <> $mousePos[0] Then
        GUICtrlSetData($xValue, $array[0])
        $mousePos[0] = $array[0]
    EndIf
    If $array[1] <> $mousePos[1] Then
        GUICtrlSetData($yValue, $array[1])
        $mousePos[1] = $array[1]
    EndIf
    Sleep(30)
WEnd
GUIDelete()

Func clearCoordinates()
    GUICtrlSetData($upperLeft, "")
    GUICtrlSetData($lowerRight, "")
    $currentCoordinate = "upper_left"
    $x1 = 0
    $y1 = 0
    $x2 = 0
    $y2 = 0
EndFunc

Func clearEdit()
    GUICtrlSetData($edit, "")
EndFunc

Func getMousePos()
    $array = MouseGetPos()
    If $currentCoordinate = "upper_left" Then
        GUICtrlSetData($upperLeft, $array[0] & ", " & $array[1])
        $x1 = $array[0]
        $y1 = $array[1]
        $currentCoordinate = "lower_right"
    ElseIf $currentCoordinate = "lower_right" Then
        GUICtrlSetData($lowerRight, $array[0] & ", " & $array[1])
        $x2 = $array[0]
        $y2 = $array[1]
        $currentCoordinate = "upper_left"
    EndIf
EndFunc

Func getPixelChecksum()
    If $x1 > $x2 Or $y1 > $y2 Then
        MsgBox(48, "Bad coordinates", "You have entered bad coordinates! The upper left corner coordinates must be above and to the left of the lower right coordinates.", 0, $mainWindow)
        clearCoordinates()
    ElseIf $x1 = 0 And $x2 = 0 And $y1 = 0 And $y2 = 0 Then
        MsgBox(48, "No coordinates", "Press Shift + Control + x to set coordinates.", 0, $mainWindow)
    Else
        $checksum = PixelChecksum($x1, $y1, $x2, $y2)

        $text = GUICtrlRead($edit)
        $varName = GUICtrlRead($globalConstInput)
        If BitAND(GUICtrlRead($findchecksum), $GUI_CHECKED) = $GUI_CHECKED Then
            $w = $x2 - $x1
            $h = $y2 - $y1
            $pcolor = PixelGetColor($x1, $y1)
        EndIf

        If BitAND(GUICtrlRead($yes), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "Global Const $" & $varName & "X1 = " & $x1 & @CRLF
            $text &= "Global Const $" & $varName & "Y1 = " & $y1 & @CRLF
            $text &= "Global Const $" & $varName & "X2 = " & $x2 & @CRLF
            $text &= "Global Const $" & $varName & "Y2 = " & $y2 & @CRLF
            $text &= "Global Const $" & $varName & "Checksum = " & $checksum & @CRLF
            If BitAND(GUICtrlRead($findchecksum), $GUI_CHECKED) = $GUI_CHECKED Then
                $text &= "Global Const $" & $varName & "W = " & $w & @CRLF
                $text &= "Global Const $" & $varName & "H = " & $h & @CRLF
                $text &= "Global Const $" & $varName & "Pcolor = " & $pcolor & @CRLF
                $w = "$" & $varName & "W"
                $h = "$" & $varName & "H"
                $pcolor = "$" & $varName & "Pcolor"
            EndIf
            $text &= "-------------------------------------------------------------------------------------" & @CRLF
            Local $tmp[5] = [$x1,$y1,$x2,$y2,$checksum]
            $x1 = "$" & $varName & "X1"
            $y1 = "$" & $varName & "Y1"
            $x2 = "$" & $varName & "X2"
            $y2 = "$" & $varName & "Y2"
            $checksum = "$" & $varName & "Checksum"
        EndIf

        If BitAND(GUICtrlRead($findchecksum), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "_findchecksum(" & $checksum & ", " & $w & ", " & $h & ", " & $pcolor & ", $hWnd)" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF
        EndIf
        If BitAND(GUICtrlRead($whileEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "While(PixelChecksum(" & $x1 & ", "  & $y1 & ", " & $x2 & ", " & $y2 & ") = " & $checksum & ")" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF
        EndIf
        If BitAND(GUICtrlRead($whileNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "While(PixelChecksum(" & $x1 & ", "  & $y1 & ", " & $x2 & ", " & $y2 & ") <> " & $checksum & ")" & @CRLF & @CRLF & "WEnd" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF
        EndIf
        If BitAND(GUICtrlRead($doEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "Do" & @CRLF & @CRLF & "Until PixelChecksum(" & $x1 & ", "  & $y1 & ", " & $x2 & ", " & $y2 & ") = " & $checksum & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF
        EndIf
        If BitAND(GUICtrlRead($doNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "Do" & @CRLF & @CRLF & "Until PixelChecksum(" & $x1 & ", "  & $y1 & ", " & $x2 & ", " & $y2 & ") <> " & $checksum & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF
        EndIf
        If BitAND(GUICtrlRead($ifEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "If PixelChecksum(" & $x1 & ", "  & $y1 & ", " & $x2 & ", " & $y2 & ") = " & $checksum & " Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF
        EndIf
        If BitAND(GUICtrlRead($ifNotEquals), $GUI_CHECKED) = $GUI_CHECKED Then
            $text &= "If PixelChecksum(" & $x1 & ", "  & $y1 & ", " & $x2 & ", " & $y2 & ") <> " & $checksum & " Then" & @CRLF & @CRLF & "EndIf" & @CRLF & "-------------------------------------------------------------------------------------" & @CRLF
        EndIf

        GUICtrlSetData($edit, $text)
        If IsDeclared("tmp") = -1 Then
            $x1 = $tmp[0]
            $y1 = $tmp[1]
            $x2 = $tmp[2]
            $y2 = $tmp[3]
            $checksum = $tmp[4]
        EndIf
    EndIf
EndFunc

Func setCoordMode($mode=2)
    deb($mode)
    AutoItSetOption("PixelCoordMode", $mode)
    AutoItSetOption("MouseCoordMode", $mode)
    GUICtrlSetState($coordModeScreen, ($mode == 1) ? $GUI_CHECKED : $GUI_UNCHECKED)
    GUICtrlSetState($coordModeWindow, ($mode == 0) ? $GUI_CHECKED : $GUI_UNCHECKED)
    GUICtrlSetState($coordModeClient, ($mode == 2) ? $GUI_CHECKED : $GUI_UNCHECKED)
EndFunc


Func deb($debugtext)
    If $debug == 1 Then
        ConsoleWrite($debugtext & @CRLF)
    EndIf
EndFunc

Big thanks to the original authors, hopefully the script will continue to be useful to the community.

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

×