Jump to content

[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
sleep(250)

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

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]
EndFunc

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
Link to comment
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
;http://www.autoitscript.com/forum/topic/56536-easy-shell-hooking-example/
;#NoTrayIcon
Opt("WinWaitDelay", 0)
;OnAutoItExitRegister("_OnExit")
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
    Sleep(1000)
WEnd

Func _OnExit()
ShellHookWindow($hGui, 0)
Exit
EndFunc

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

;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]
EndFunc
;register window message

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

I see fascists...

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