Jump to content

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.

Link to comment
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

 

Link to comment
Share on other sites

It is working fine on my comp.  Make sure you got the most recent version of autoit, fully installed with the autoit installer.  Look in the include folder for that specific file.  It is quite a basic script.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

@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===

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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