Jump to content

Help Checksum


Huggen
 Share

Recommended Posts

Hey all need help with this script quite simple....I need it to check 2 areas if one of them changes it should say

MsgBox(0, "", "Something in the 1 region has changed!") or MsgBox(0, "", "Something in the 2 region has changed!")

but it spamms:

MsgBox(0, "", "Something in the 1 region has changed!")

and it haven´t.....what script should work?

HotKeySet('{F6}', '_Start')
HotKeySet('{F7}', 'stop')
HotKeySet('{F8}', 'end')
While 1
    Sleep(25)
Wend
Func stop()
    While 1
    Sleep(25)
Wend
EndFunc

Func _Start()
While 1=1

; Wait until something changes in the region 0,0 to 50,50

; Get initial checksum
$checksum = PixelChecksum(0,0, 50,50)
$checksum1 = PixelChecksum(50,50, 100,50)
; Wait for the region to change, the region is checked every 100ms to reduce CPU load
sleep(100)
if $checksum = PixelChecksum(0,0, 50,50) Then
    MsgBox(0, "", "Something in the 1 region has changed!")
elseif $checksum1 = PixelChecksum(50,50, 100,50) Then
    MsgBox(0, "", "Something in the 2 region has changed!")
endif




    WEnd
EndFunc

Func end()
    Exit
EndFunc
Link to comment
Share on other sites

I havent tested the your code , but one potential problem I see is the "Get initial checksum" is Inside your while loop shouldnt it be like this? If not, I may not understand exactly wutt u mean to try?

Edited by ofLight

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

Oppp, I also Saw, u need to change your

if $checksum1 = PixelChecksum(0,0, 50,50) Then

to

if $checksum1 <> PixelChecksum(0,0, 50,50) Then

HotKeySet('{F6}', '_Start')
HotKeySet('{F7}', 'stop')
HotKeySet('{F8}', 'end')

While 1
    Sleep(25)
Wend

Func stop()
    While 1
        Sleep(25)
    Wend
EndFunc

Func _Start()
    ; Get initial checksum
    $checksum1 = PixelChecksum(0,0, 50,50)
    $checksum2 = PixelChecksum(50,50, 100,50)
    
    While 1 ; Wait for the region to change, the region is checked every 100ms to reduce CPU load
        if $checksum1 <> PixelChecksum(0,0, 50,50) Then
            MsgBox(0, "", "Something in the 1 region has changed!")
            ExitLoop
        elseif $checksum2 <> PixelChecksum(50,50, 100,50) Then
            MsgBox(0, "", "Something in the 2 region has changed!")
            ExitLoop
        endif
        sleep(100)
    WEnd
EndFunc

Func end()
    Exit
EndFunc
Edited by ofLight

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

I don't know If I understood everything but shouldn't it be:

HotKeySet('{F6}', '_Start')
HotKeySet('{F7}', 'stop')
HotKeySet('{F8}', 'end')

While 1
    Sleep(25)
Wend

Func stop()
    While 1
        Sleep(25)
    Wend
EndFunc

Func _Start()
    ; Get initial checksum
    $checksum = PixelChecksum(0,0, 50,50)
    $checksum1 = PixelChecksum(50,50, 100,50)
   
    While 1
        ; Wait until something changes in the region 0,0 to 50,50

        ; Wait for the region to change, the region is checked every 100ms to reduce CPU load
        sleep(100)
        if $checksum <> PixelChecksum(0,0, 50,50) Then  ; is NOT
            $checksum = PixelChecksum(0,0, 50,50) ; get new default
            MsgBox(0, "", "Something in the 1 region has changed!")
            Sleep(100) ; wait some time to let the old window be active again
        elseif $checksum1 <> PixelChecksum(50,50, 100,50) Then  ; is NOT
            $checksum1 = PixelChecksum(50,50, 100,50) ; get new default
            MsgBox(0, "", "Something in the 2 region has changed!")
            Sleep(100) ; wait some time to let the old window be active again
        endif

    WEnd
EndFunc

Func end()
    Exit
EndFunc

senthor

Edited by senthor
Link to comment
Share on other sites

Yea, thanks to all....I learn something :mellow:

but still not working (like I it should)

It seems to me that it can´t be more than 1 "PixelChecksum()" in a function....

but I maybe wrong?

too them that diden´t understand what I wanted was. it checks to areas.... 1 and 2

if area 1 changes then it says " area 1 have change"

and if area 2 changes it says " area 2 have change"

did you all get it now?

EDIT: btw never mind....I´m so dumb thought wrong about the x and y on the window....script works thanks all :(

Edited by Huggen
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...