Jump to content
Sign in to follow this  
frontmill

Pixelchecksum Search

Recommended Posts

frontmill

i was wondering if someone knows a way to search the screen for a checksum returned by PixelChecksum?

Share this post


Link to post
Share on other sites
SmOke_N

i was wondering if someone knows a way to search the screen for a checksum returned by PixelChecksum?

Well, that's a fairly broad question... If known the size of the area (Width/Height) you want to search, then with a simple (maybe 2? :) ) Loop you could probably accomplish this. << (Answer as vague as the question?)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
frontmill

yeah very vague indeed... i will explain what I want to use for: i am working on a cheat for an online game I play. The main target of this game is clicking the same button over and over :)... But since the postion of the button is diffrent per resolution and per time you refresh the page, i want the program to search for the button and then press it... hopw you understand it now...

thanks in advance...

Share this post


Link to post
Share on other sites
SmOke_N

You could try this, I coded it on the fly and did not test it, but should give you somewhere to start if it doesn't work:

#cs
Example below of what does what:
Local $WindowNameToSearch = 'SomeTitle'; Title of window to search
Local $SumToFind = 123456789; Only an example, assuming that you've already gotten that information
Local $WidthToSearch = 50; Put in how wide the button area is that you found the SumToFind value
Local $HeightToSearch = 30; Put in the height of the area is that you found the SumToFind value
Local $ClientSize = WinGetClientSize($WindowNameToSearch)
#ce

Opt('MouseCoordMode', 2); Since the pixel location will be in client coords so should the mouseclick
$MClick = _PixelCheckSumFind('SomeTitle', 123456789, 50, 30, WinGetClientSize('SomeTitle'))
If IsArray($MClick) Then
    MouseClick("Primary", $MClick[1], $MClick[2], 1, 1)
Else
    MsgBox(64, 'InfoMain:', 'No button found')
EndIf

Func _PixelCheckSumFind($WindowNameToSearch, $SumToFind, $WidthToSearch, $HeightToSearch, $ClientSize)
    $OptPix = Opt('PixelCoordMode', 2); Set for client coords
    Local $FoundButton = 0
    For $xCount = 0 To ($ClientSize[0] - $WidthToSearch)
        For $yCount = 0 To ($ClientSize[1] - $HeightToSearch)
            $SearchingSum = PixelChecksum($xCount, $yCount, $WidthToSearch, $HeightToSearch)
            If $SearchingSum = $SumToFind Then
;The Message box from here to >>>
                MsgBox(64, 'Info:', 'Found Button at: ' & @CR & _
                $xCount & $yCount & @CR & _
                'You probably would set your MouseClick up like this: ' & @CR & _ 
                'MouseClick("Primary", ' & $xCount + ($WidthToSearch / 2) & ',' & $yCount + ($HeightToSearch / 2) & ', 1, 1)') 
; <<< Message box to here can be deleted, but use it to test if it works
                $FoundButton = 1
                ExitLoop; We found the button, we don't need to search anymore
            EndIf
        Next
    Next
    Opt('PixelCoordMode', $OptPix); Reset PixelSearch back to it's previous
    If $FoundButton = 1 Then Return StringSplit($xCount + ($WidthToSearch / 2) & Chr(01) & $yCount + ($HeightToSearch / 2), Chr(01), 1)
    SetError(1)
    Return 0
EndFunc

Edit:

Now that I think about this, I believe Larry's PixelFindArea() or PixelAreaFind() :) would do just as well if not better, I say that because I think you can put in a unique color to PixelSearch for, and it plugs away for you if I'm not mistaken.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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
Sign in to follow this  

×