windows Taskbar Icon Blink and Progress Bar

Started by galaara98, October 23, 2014, 09:44:16 AM

Previous topic - Next topic

galaara98

so this isn't NECESSARILY a pure Winbatch Dialog question, because i also wonder how i could do this with a Box()

In windows 7+ (and maybe XP)
when an Application is Normalize, but not the top window.  There appears to be a way to Blink your "button"/Icon on the Windows Taskbar, when you want to tell the user you have something important to show

also when an application is busy, but knows a certain %complete of the current task, i have seen Icons overlay a progress bar on their "button"/icon on the Windows Taskbar.

Can I do either or both of those?
In MY personal situation,
.   i have a Dialog that could benefit from the "Blink, i need attention",
.         and has a Text progress bar concept (X of Y, Z% Done in a status area) that would benefit from the Over-layed Progress bar
.   and a Box that i use calculated rectangles to simulate a progress bar (much like winbatch setup.exe) that i would love to show that data on the Taskbar Icon.

but knowing how to do either only in the context of Dialog would be super helpful

Aaron

kdmoyers

I make the task bar icon flash using this below.  No idea how to do the cool progress bar effect.
-Kirby
Code (winbatch) Select
  #definefunction FlashWindowEx(title, count)
    ; automatically flash {title} window taskbar icon and window border.
    ; if {count} is positive, stops automatically after {count} flashes
    ; if {count} is zero, stop flashing now.
    ; if {count} is negative, stops automatically after {count} seconds
    ;
    if count < 0
      ; this is double the rate of window flashes for the FlashWindow call
      msBlinkRate = regqueryvalue(@REGCURRENT, "Control Panel\Desktop[CursorBlinkRate]")
      ; compute number of flashes
      count = int((0-count)*1000.0 / msBlinkRate / 2.0)
    endif
    winhan = DllHwnd(title)
    user32=StrCat(DirWindows(1),"User32.dll")
    @FLASHW_ALL = 3        ; Flash both the window caption and taskbar button
    @FLASHW_CAPTION = 1    ; Flash the window caption.
    @FLASHW_STOP = 0       ; Stop flashing. The system restores the window to its original state.
    @FLASHW_TIMER = 4      ; Flash continuously, until the FLASHW_STOP flag is set.
    @FLASHW_TIMERNOFG = 12 ; Flash continuously until the window comes to the foreground.
    @FLASHW_TRAY = 2       ; Flash the taskbar button.
    if count == 0
      dwFlags = @FLASHW_STOP
    else
      dwFlags = @FLASHW_TRAY ; @FLASHW_TRAY or @FLASHW_CAPTION or @FLASHW_ALL
    endif
    bFWI = binaryalloc(20)
    BinaryPoke4( bFWI,  0, 20)      ; cbSize (size of this struct)
    BinaryPoke4( bFWI,  4, winhan)  ; hwnd
    BinaryPoke4( bFWI,  8, dwFlags) ; dwFlags
    BinaryPoke4( bFWI, 12, count)   ; uCount (number of flashes to do)
    BinaryPoke4( bFWI, 16, 0)       ; dwTimeout (in ms, or zero for default blink rate)
    BinaryEODSet(bFWI, 20) 
    ret = DllCall(user32, long:"FlashWindowEx", lpbinary:bFWI)
    Binaryfree(bFWI)
    return ret != 0         ; ret true if window *was* active before call
  #endfunction
The mind is everything; What you think, you become.

galaara98

When i call this UDF do i get control back immediately or after the flashing finishes

Aaron

galaara98

Quote from: kdmoyers on October 23, 2014, 11:56:09 AM
I make the task bar icon flash using this below.  No idea how to do the cool progress bar effect.
-Kirby
Code (winbatch) Select
  #definefunction FlashWindowEx(title, count)
    ; automatically flash {title} window taskbar icon and window border.
    ; if {count} is positive, stops automatically after {count} flashes
    ; if {count} is zero, stop flashing now.
    ; if {count} is negative, stops automatically after {count} seconds
    ;
    if count < 0
      ; this is double the rate of window flashes for the FlashWindow call
      msBlinkRate = regqueryvalue(@REGCURRENT, "Control Panel\Desktop[CursorBlinkRate]")
      ; compute number of flashes
      count = int((0-count)*1000.0 / msBlinkRate / 2.0)
    endif
    winhan = DllHwnd(title)
    user32=StrCat(DirWindows(1),"User32.dll")
    @FLASHW_ALL = 3        ; Flash both the window caption and taskbar button
    @FLASHW_CAPTION = 1    ; Flash the window caption.
    @FLASHW_STOP = 0       ; Stop flashing. The system restores the window to its original state.
    @FLASHW_TIMER = 4      ; Flash continuously, until the FLASHW_STOP flag is set.
    @FLASHW_TIMERNOFG = 12 ; Flash continuously until the window comes to the foreground.
    @FLASHW_TRAY = 2       ; Flash the taskbar button.
    if count == 0
      dwFlags = @FLASHW_STOP
    else
      dwFlags = @FLASHW_TRAY ; @FLASHW_TRAY or @FLASHW_CAPTION or @FLASHW_ALL
    endif
    bFWI = binaryalloc(20)
    BinaryPoke4( bFWI,  0, 20)      ; cbSize (size of this struct)
    BinaryPoke4( bFWI,  4, winhan)  ; hwnd
    BinaryPoke4( bFWI,  8, dwFlags) ; dwFlags
    BinaryPoke4( bFWI, 12, count)   ; uCount (number of flashes to do)
    BinaryPoke4( bFWI, 16, 0)       ; dwTimeout (in ms, or zero for default blink rate)
    BinaryEODSet(bFWI, 20) 
    ret = DllCall(user32, long:"FlashWindowEx", lpbinary:bFWI)
    Binaryfree(bFWI)
    return ret != 0         ; ret true if window *was* active before call
  #endfunction


Now this is what i found on the, what i am now calling "the interwebby" :)

but the gist of it is you need to implement the ITaskbarList3 Interface, and then use the SetProgressState to set the state (Normal, Error, Paused, or Marquee) and SetProgressValue to set the value.  (http://msdn.microsoft.com/en-us/library/windows/desktop/dd391692%28v=vs.85%29.aspx)

However i can honestly say i do most of my Windows programming within the world of Winbatch, and Powershell...
     neither of those directly help me ingest the knowledge base article in a way i can use it.. But some of you folks out there seem to know how to convert these concepts into usable Winbatch code... :)

td

The ITaskbarList3  interface is part of the Windows shell API and like most shell APIs is COM based.  Since it is not a dual interface, there is no way to instantiate a COM object and call its methods directly using WinBatch COM Automation.  You cannot use WinBatch DllCall and other supporting functions to call COM methods or properties either.  This leaves you the alternatives of either a WIL extender or a dotNet wrapper assembly.  The former would require knowledge of C++, WIL exender implementation and COM early bind programming.  The latter requires a knowledge of C# or VB dotNet, the FCL and COM interop.  The dotNet solution may be the better of the two because you can likely find an assembly already coded for you.  Your search engine of choice is your friend here. 

Keep in mind that the official ITaskbarList3 interface is not supported on systems older than Windows 7.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

<<When i call this UDF do i get control back immediately or after the flashing finishes>>

control comes back immediately.  The whole flashy thing happens by iteself. It's wonderful.

-Kirby
The mind is everything; What you think, you become.