Sign in to follow this  
Followers 0
Kero

Problem with PixelChecksum

12 posts in this topic

#1 ·  Posted (edited)

Here is part of my code of two functions. For some reason, the while loop freezes inside a full screened game unless I minimize the game.

Func CheckLogin()
    $login = "-1"
    While $login <> "0"
        MouseClick("left",731,53)
        MouseClick("left",0,0)
        If CheckLogin2()="1" Then
            MouseClick("left",680,683)
            StartGame()
            $login = "0"
        ElseIf CheckLogin2()="2" Then
            Send("{ENTER}{ENTER}")
        ElseIf CheckLogin2()="3" Then
            MouseClick("left",680,683)
            StartGame()
            $login = "0"
        ElseIf CheckLogin2()="4" Then
            SelectCharacter()
            $login = "0"
        EndIf
    WEnd
EndFunc

Func CheckLogin2()
    If PixelChecksum(558,490,598,508,1)="3517004610" Then 
        Return 1
    ElseIf PixelChecksum(0,911,89,945)="166012633" Then
        Return 2
    ElseIf PixelChecksum(0,911,89,945)="976319356" Then 
        Return 3
    ElseIf PixelChecksum(99,120,99,120)="45220162" Then 
        Return 4
    EndIf
EndFunc
Edited by Kero

Share this post


Link to post
Share on other sites



i tried adding Opt("TrayIconDebug", 1) in the beginning of the program, it does nothing.

Share this post


Link to post
Share on other sites

when the window is full screen, do you still have the start bar, or is it hidden? If it is hidden, you may need to debug by writting to console to see what is happening.

I see no bar. I made a GUICtrlCreateEdit that output things I wrote in the program. The problem I found is that the while loop freezes until I focus that GUICtrlCreateEdit window.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I'm thinking outside the box here, but is it possible to have the output written to a text file, and each time a line is written, a time stamp is done at the beginning of the line. This way you could see where it hangs without the window issue messing you up in debuging.

Edited by vollyman

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I changed this a bit of the code, it still seems to freeze unless I press the gui window.

Func CheckLogin()
    $login = "-1"
    
    While $login <> 0
        Addstatus("Checking Login")
        
        $login = CheckLogin2()
        
        If $login="1" Then
            MouseClick("left",680,683)
            StartGame()
            $login = "0"
        ElseIf $login="2" Then
            Send("{ENTER}{ENTER}")
        ElseIf $login="3" Then
            MouseClick("left",680,683)
            StartGame()
            $login = "0"
        ElseIf $login="4" Then
            SelectCharacter()
            $login = "0"
        EndIf
    WEnd
EndFunc

Func CheckLogin2()
    AddStatus("CheckLogin2()")
    If PixelChecksum(558,490,598,508,1)="3517004610" Then
        AddStatus("1")
        Return 1
    ElseIf PixelChecksum(0,911,89,945)="166012633" Then
        AddStatus("2")
        Return 2
    ElseIf PixelChecksum(0,911,89,945)="976319356" Then
        AddStatus("3")
        Return 3
    ElseIf PixelChecksum(99,120,99,120)="45220162" Then
        AddStatus("4")
        Return 4
    Else
        AddStatus("-1")
        Return -1
    EndIf
EndFunc
Edited by Kero

Share this post


Link to post
Share on other sites

could it be possible the checksum is slow because it is under full screen?

Share this post


Link to post
Share on other sites

try using message boxes at intervals... if possable... i didnt really go through all your code i dont have time, but thats what i do, or make tooltips... like i did with this nifty prog...

do
$pos = MouseGetPos()
$color = PixelGetColor ( $pos[0] , $pos[1] )
ToolTip ( $pos[0] & "," & $pos[1] & @LF & $color );, $pos[0] , $pos[1] )
until 1 = 2

Just shows the mouse pos and color, but you get the idea. Anyways, i really need to get going, but i hope this helps...

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

heh, aonlan i guess ? 8) anyways its pretty hard to say just w/ partial code.

i could help you out if your willing to give me your source, as i dont have anything better to do atm (:

if no, then you should use msgboxes / tooltips to find out where it stucks as suggested above.

:edit

played around a bit, this wont get stuck unless all pixelchecksums are different from set values or SelectCharacter/StartGame funcs are stuck 8)

MsgBox(0, "test", CheckLogin())

Func CheckLogin()
    Local $Login
    Local $Return
    
    While 1
        MouseClick("left",731,53)
        MouseClick("left",0,0)
        $Login = CheckLogin2()
        Select
            Case $Login = 1
                MouseClick("left",680,683)
                StartGame()
                $Return = "StarGame func executed, $Login was = " & $Login
                ExitLoop
                
            Case $Login = 2
                Send("{ENTER}{ENTER}")
            
            Case $Login = 3
                MouseClick("left",680,683)
                StartGame()
                $Return = "StarGame func executed, $Login was = " & $Login
                ExitLoop
            
            Case $Login = 4
                SelectCharacter()
                $Return = "SelectCharacter func executed, $Login was = " & $Login
                ExitLoop
                
            Case Else
                Sleep(100); CheckLogin2 returned 0, PixelChecksums <> set values
        EndSelect
    WEnd
    Return $Return
EndFunc

Func CheckLogin2()
    Select
        Case PixelChecksum(558,  490, 598, 508, 1) = "3517004610"
            Return 1
        
        Case PixelChecksum(0, 911, 89, 945) = "166012633"
            Return 2
        
        Case PixelChecksum(0, 911, 89, 945) = "976319356"
            Return 3
        
        Case PixelChecksum(99, 120, 99, 120) = "45220162"
            Return 4
        
        Case Else 
            Return 0
    EndSelect
EndFunc
Edited by julmae

Share this post


Link to post
Share on other sites

I am a friend of aon

Share this post


Link to post
Share on other sites

Whats the game?

If screen colors are nop exactly the same each time then pixelchecksum will fail and thus a endless loop.

What is addstatus?

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