Jump to content

PixelSearch region check addition to code, how??


reese646
 Share

Recommended Posts

Right I've had a good time this morning, and my first post resulted in a great solution to an alarm for changes to a region, I have tidied that thread up and marked it as solved as the questions I was additionally asking we're going of the original topic and I only have one more message left today? (any help on getting aditional messages would be appreciated).
 
Anyway Ive took this code.

; Provide a way to exit
HotKeySet("{+}", "On_Exit") ;uses the + key to exit the program

; Get an initial checksum
$nCurr_Checksum = PixelChecksum(0, 0, 400, 400);alter this region to the region requiring monitoring

; Start the loop
While 1
    ; Get a new checksum
    $nNew_Checksum = PixelChecksum(0, 0, 400, 400) ;alter this to match the PixelCheckSum above
    ; See if the area has changed
    If $nNew_Checksum <> $nCurr_Checksum Then
        ; If so then notify
        SoundPlay(@WindowsDir & "\Media\notify.wav", 1) ;\media\notify.wav can be changed to any other audible file
        ConsoleWrite("!Changed" & @CRLF)
        ; And reset the checksum to check against next time round
        $nCurr_Checksum = $nNew_Checksum
    EndIf
    ; Wait 1 sec and do it all again
    Sleep(400) ;in milliseconds altering this changes how quickly the script refreshes
WEnd

Func On_Exit()
    Exit
EndFunc

this provides an alarm for an area should it change, and resets once the alarm has sounded.

The problem is transparency, the messenger window I'm monitoring has a transparency so things behind it are setting off the alarm, so I believe I need to add a PixelSearch to the code, have tried a few and getting errors, tried this and no errors, but no alarm, and help appreciated.

; Provide a way to exit
HotKeySet("{+}", "On_Exit") ;uses the + key to exit the program

; Get an initial checksum
$nCurr_Checksum = PixelChecksum(2129, 448, 2220, 1200);alter this region to the region requiring monitoring

; Start the loop
While 1
    ; Get a new checksum
    $nNew_Checksum = PixelChecksum(2129, 448, 2220, 1200) ;alter this to match the PixelCheckSum above
    ; See if the area has changed
    If $nNew_Checksum <> $nCurr_Checksum And PixelSearch (2129, 448, 2220, 1200, 0x252424 ,2 ) Then
        ; If so then notify
        SoundPlay(@WindowsDir & "\Media\notify.wav", 1) ;\media\notify.wav can be changed to any other audible file
        ConsoleWrite("!Changed" & @CRLF)
        ; And reset the checksum to check against next time round
        $nCurr_Checksum = $nNew_Checksum
    EndIf
    ; Wait 1 sec and do it all again
    Sleep(400) ;in milliseconds altering this changes how quickly the script refreshes
WEnd

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

  • Moderators

reese646,

I have lifted your "New Member" posting restriction. :)

Now I will look at your question. ;)

M23

Edit:

I am not at all sure that PixelSearch is going to help here if the background is changing and affecting teh colours in an area. Some screenshots of the messenger window before and after a "real" notification and when the background is "changing" between these 2 points would be a great help. We might be able to identify something more specific that you can use to indicate the "real" change. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

hi, just checking back in on the fly so can't sort any pictures out at the minute, as asked about the change in colour I'd say the transparency is only 5-8 percent and so is only very mildly affecting the base colour as a light shimmer if you know what I mean, similar I suppose to windows aero transparency, but this very slight pixel tinting is enough obviously to give a false positive, hence my thinking that if a pixelsearch could be implemented after the pixelchecksum as a secondary condition then it would solve the problem, implementing it is the current problem, changing the colour variation in the pixelsearch variables is something I can play with once I've got something to work with.

Have tried a few things and worked my way through some of the tutorials and its really interesting, but I'm struggling to apply this knowledge so far to the problem in  hand.

Many thanks

Link to comment
Share on other sites

  • Moderators

reese646,

Another thought - how about putting a non-transparent window underneath the messenger GUI? That way you can prevent the background from showing through. It is quite easy to get an AutoIt GUI to "follow" another so that you do not have to keep the messenger window in a fixed position. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...