Jump to content
ttt480

How to script autoit to recognize the flashing in the window and give a Msgbox of "Flashing" ?

Recommended Posts

Hello, friends.

Tell me how to script autoit to recognize the flashing in the window.

That is, periodically in window 1.exe flashes at a constant frequency.

Flashing is a frequent and abrupt change of color for 3 seconds.

Share this post


Link to post
Share on other sites

NineI cannot run this script.

Writes "#include <WinAPISysWin.au3> Error opening the file".

#include <APISysConstants.au3>
#include <WinAPISysWin.au3>

Opt('TrayAutoPause', 0)

OnAutoItExitRegister('OnAutoItExit')

Global $g_hForm = GUICreate('')
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK')
_WinAPI_RegisterShellHookWindow($g_hForm)

While 1
    Sleep(1000)
WEnd

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg

    Switch $hWnd
        Case $g_hForm
            Local $sTitle = WinGetTitle($lParam)
            Switch $wParam
                Case $HSHELL_FLASH
                    If IsString($sTitle) Then
                        ConsoleWrite('Redrawn: ' & $sTitle & @CRLF)
                    EndIf
                Case Else
                    If BitAND($wParam, $HSHELL_WINDOWACTIVATED) = $HSHELL_WINDOWACTIVATED And IsString($sTitle) Then
                        ConsoleWrite('Activated: ' & $sTitle & @CRLF)
                    EndIf
            EndSwitch
    EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func OnAutoItExit()
    _WinAPI_DeregisterShellHookWindow($g_hForm)
EndFunc   ;==>OnAutoItExit

 

Share this post


Link to post
Share on other sites

NinePlease explain how this script recognizes the flash in the window ?

Does it somehow track the color change of the window pixels ?

Share this post


Link to post
Share on other sites

Nope, it is a message sent.  You need to change your paradigms about detecting pixels or color changes (that will not work at all). Whenever there is an action to be performed, most of those actions are sent through notification (or message if you prefer).  In this case, the script intercepts the request for the form (or window handle if you prefer) to flash.  Then instead of checking whatever change in color, you can perform your usual tasks and wait the desired window to flash.

You must read about messages and notifications to fully understand how it is working, but in the mean time, just use the code I gave you, modify it to your needs, and work your way up.

Share this post


Link to post
Share on other sites

NineWhat notifications are we talking about ?

I asked about the reaction of the script autoit, the appearance of flashing in the window.

No messages appear in the window, only at a certain moment the window is flashing.

And I asked how to react to this moment.

Share this post


Link to post
Share on other sites
Posted (edited)

Hes talking about messages that components send to each other to perform specific actions. There is no actual message saying "this action is being performed" that is displayed to the user.

 

That being said if you are looking to the script visually detect flashing in a window it is technically possible assuming the flashing is always done in a specific color. For example if one portion of the window is red, but when it flashes it becomes a brighter shade of red you can use PixelGetColor  to detect the color change. It would look something like this:

 

while PixelGetColor ( x , y [, hwnd] ) <> $colorOfFlashingPixel
sleep(100)
wend 
Msgbox(0,"Alert","Window is flashing!")

 

You can use autoit window info to get the color,

But once again this assumes that the flashing color you are looking for is always the same and in the same location (or you can determine the location every time).

Edited by ComradVlad

Share this post


Link to post
Share on other sites

@ttt480 other than your seizure inducing video (which I removed for its stupidity) you have yet to explain precisely what you are attempting to do. What application are you working with (window 1.exe doesn't cut it) and what causes the window to "flash at a constant frequency". More detail and fewer vague responses will help us help you.

 

                                                                                        ===In case you missed it, this is a Mod stepping into a thread===

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

×
×
  • Create New...