Jump to content
Sign in to follow this  

[Solved] Detect Window Flashing

Recommended Posts


I had to take a break from autoit coding ;) because of uni work but i want to get back into it.

One of the projects i was working on was working with chat-programs.

Opt('WinTitleMatchMode', 2 )

while 1

;Show Chat Messages
$Steam = WinGetState("- Chat", "")
If  _Flash("- Chat") <> 0 Then
    if BitAnd($Steam, 16) Then
            WinSetState("- Chat","",@SW_RESTORE)

Func _Flash($win)
    If WinActive($win) Then Return 0
    $tFLASHWINFO = DllStructCreate("uint;hwnd;dword;uint;dword")
    DllStructSetData($tFLASHWINFO, 1, 20)
    DllStructSetData($tFLASHWINFO, 2, WinGetHandle($win))
    $a = DllCall("user32.dll", "int", "FlashWindowEx", "ptr", DllStructGetPtr($tFLASHWINFO))
    Return $a[0]

I dont understand the _Flash Function, but when steam gets a message "turning orange" to detects this. Checks the chat-program is minimized and if so, restores it. "Making it so, when i get a message from someone it shows me the message".

Now the problem is, though this code works for steam chat it doesn't work for msn or skype. "Same code but using skype/msn window titles".

So i was wondering if everyone does understand this function, and could help me understand why it doesn't work for these two applications.

Edited by IanN1990

Share this post

Link to post
Share on other sites

Aye, as you have already pointed out there are Autoi functions which is/are able to make applications flash ;)

As for the detection, i checked out ur RegisterShellHookWindow link but honestly cant make heads or tails of it :)

Share this post

Link to post
Share on other sites

There are numerous posts on this

look for RegisterShellHookWindow / HSHELL_FLASH events

some links here

Intercepting a Window Message

edited from an example by Siao

;from Siao example
Opt("WinWaitDelay", 0)
HotKeySet("{ESC}", "_OnExit")

;ShellHook notification codes:
Global Const $HSHELL_FLASH = 32774;
Global $bHook = 1
;GUI stuff:
Global $hGui = GUICreate("", 1, 1, -100, -100)
;Hook stuff:
GUIRegisterMsg(RegisterWindowMessage("SHELLHOOK"), "HShellWndProc")
ShellHookWindow($hGui, $bHook)

While 1

Func _OnExit()
ShellHookWindow($hGui, 0)

Func HShellWndProc($hWnd, $Msg, $wParam, $lParam)
    Switch $wParam
        Case $HSHELL_FLASH
   ConsoleWrite("-Window flash hWnd: " & $lParam & " (" & WinGetTitle($lParam) & ")" & @CRLF)

;register/unregister ShellHook
Func ShellHookWindow($hWnd, $bFlag)
    Local $sFunc = 'DeregisterShellHookWindow'
    If $bFlag Then $sFunc = 'RegisterShellHookWindow'
    Local $aRet = DllCall('user32.dll', 'int', $sFunc, 'hwnd', $hWnd)
    Return $aRet[0]
;register window message

Func RegisterWindowMessage($sText)
    Local $aRet = DllCall('user32.dll', 'int', 'RegisterWindowMessageW', 'wstr', $sText)
    Return $aRet[0]
Edited by rover

I see fascists...

Share this post

Link to post
Share on other sites

Thanks for your help rover and dccd ;) with this code i should be able to get everything workin

**Edit thanks again :D now when i get a message for steam, skype or msn it "restores" the message so i can see. Before it only worked for steam :) Nice to see projects coming togeather

Edited by IanN1990

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