AutoHotkey Community

It is currently May 26th, 2012, 10:17 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Stop taskbar blinking
PostPosted: October 23rd, 2009, 6:32 pm 
Offline

Joined: November 6th, 2005, 6:43 pm
Posts: 72
This program does everything possible to keep background windows from flashing the taskbar. (IM clients drive me nuts when I'm trying to get work done -- inverting the taskbar color is enough, blinking is unnecessary)

Code:
#SingleInstance force
#WinActivateForce           ; this may prevent task bar buttons from flashing when different windows are activated quickly one after the other


DetectHiddenWindows, On
Script_Hwnd := WinExist("ahk_class AutoHotkey ahk_pid " DllCall("GetCurrentProcessId"))
DetectHiddenWindows, Off
; Register shell hook to detect flashing windows.
DllCall("RegisterShellHookWindow", "uint", Script_Hwnd)
OnMessage(DllCall("RegisterWindowMessage", "str", "SHELLHOOK"), "ShellEvent")


ShellEvent(wParam, lParam) {
    if (wParam = 0x8006) ; HSHELL_FLASH
    {   ; lParam contains the ID of the window which flashed

        FlashWindowEx(lParam, FLASHW_STOP:=0, 0, 65535)

        ; Depending on which application you're trying
        ; to tame, the above may not work, because
        ; some applications call FlashWindow() repeatedly
        ; instead of calling FlashWindowEx() once.
        ; So, we may have to resort to:

        WinGet, hwndWasFocused, ID, A       ; remember which window originally had the focus
        BlockInput, On                      ; we can't stop keystrokes from being lost, but we can stop them from going to the wrong application
        WinActivate, ahk_id %lParam%
        WinActivate, ahk_id %hwndWasFocused%
        BlockInput, Off
    }
}



; thanks to SKAN    http://www.autohotkey.com/forum/post-280244.html#280244
;
; dwFlags can be a bitwise combination of:
;   FLASHW_ALL := 3        ; Flash both the window caption and taskbar button. This is  equivalent to setting FLASHW_CAPTION|FLASHW_TRAY flags.
;   FLASHW_CAPTION := 1    ; Flash the window caption.
;   FLASHW_STOP := 0       ; Stop flashing. The system restores the window to its orig. state.
;   FLASHW_TIMER := 4      ; Flash continuously, until the FLASHW_STOP flag is set.
;   FLASHW_TIMERNOFG := 12 ; Flash continuously until the window comes to foreground.
;   FLASHW_TRAY := 2       ; Flash the taskbar button.
FlashWindowEx( hWnd=0, dwFlags=0, uCount=0, dwTimeout=0 ) {
    Static FW="0123456789ABCDEF01234" ; FLASHWINFO Structure
    NumPut(20,FW), NumPut(hWnd,FW,4), NumPut(dwFlags,FW,8), NumPut(uCount,FW,12), NumPut(dwTimeout,FW,16)
    Return DllCall( "FlashWindowEx", UInt,&FW )
}

It's not a perfect solution though, because it ends up blocking some keystrokes if you're typing when the other window flashes, and it produces visual flicker. That's almost as annoying as the blinking. A much better solution would be to use DLL-injection to block all calls to FlashWindow() and FlashWindowEx(), system-wide, but that's beyond AHK's capability.

Yes, it's true that TweakUI and HKEY_CURRENT_USER\Control Panel\Desktop\ForegroundFlashCount can reduce the amount of flashing. Unfortunately, that parameter doesn't affect programs that use FlashWindow() instead of FlashWindowEx(), so sometimes more extreme measures are needed.

Update: Further investigation shows that the OS just maps FlashWindow() calls to FlashWindowEx(). Ergo, the registry entry must apply to both functions. Nonetheless, I'm pretty sure there are times when the registry entry doesn't work, so I still think that extra measures are required, but I don't have the right explanation for why.


Last edited by interiot on February 9th, 2010, 5:41 pm, edited 6 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 12:12 am 
Offline

Joined: November 10th, 2007, 3:30 am
Posts: 93
Location: Second star to the right.... watching you.
Would be cool to get rid of the flashing via injected dll me thinks.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: spg SCOTT and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group