aa2zz6

Mapping Pixel Loader Tool

1 post in this topic

#1 ·  Posted (edited)

I'm trying to setup a pixel loader to scan tool icons on our mapping tools to replace sleep() function. While a tool is processing the idea is to scan the areas with the tool icon to capture the pixel colors and repeat until the tool popup appears with the results allowing the program to close the popups and continue loop. I've defined one section with coordinates to capture the icon but I can't figure out how to write/store each pixel coordinate x, y, and pixel color.  

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <File.au3>

Opt('PixelCoordMode', 1)

Global $sLogFile = @ScriptDir & '\Original Pixel Checker.ini'

If $CmdLine[0] = 1 Then $sLogFile = $CmdLine[1]

_PixelScan(115, 804, 479, 829) ;topleft x, topleft y, bottomright x, bottomright y

Func _PixelScan($left, $top, $right, $bottom)
    ActiveWindow()
    $PixelCount = Abs($left - $right) + Abs($top - $bottom)
    Dim $aPixelMap[$PixelCount + 1][3]
    $aPixelMap[$PixelCount][0] = UBound($aPixelMap)
    ConsoleWrite('Total number of pixels to check: ' & $aPixelMap[$PixelCount][0] & @LF)

    For $i = 1 To $aPixelMap[$PixelCount][0] - 1

        $x = $left + $i
        $y = $top + $i
        $aPixelMap[$i][0] = Hex(PixelGetColor($x, $y), 6)
        $aPixelMap[$i][1] = $x
        $aPixelMap[$i][2] = $y

        ConsoleWrite('Pixel at: ' & $aPixelMap[$i][1] & ',' & $aPixelMap[$i][2] & ' has color ' & $aPixelMap[$i][0] & @LF)

        FileWrite($sLogFile, $aPixelMap[$i][0] & "|" & $aPixelMap[$i][1] & "|" & $aPixelMap[$i][2] & @CRLF)
    Next
EndFunc   ;==>_PixelScan

Func ActiveWindow()
    $hWnd1 = WinGetHandle("[CLASS:Qt5QWindowIcon]")
    If IsHWnd($hWnd1) Then
        WinActivate($hWnd1)
    EndIf
EndFunc   ;==>ActiveWindow

Update: I was able to figure out how to write to ini and record pixel color and coordinates. Is there a way to examine 2 files against each other based off pixels since the coordinates should maintain the same location?

Edited by aa2zz6
Update

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