WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Boxes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Flash Window

 Keywords:  FlashWindowEx Blink Flash Window Box Icon DllCall

  #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 = 1       ; Flash the taskbar button.
    If count == 0
      dwFlags = @FLASHW_STOP
    Else
      dwFlags = @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

  x = 6

  ; Flash WIL Box
  FlashWindowEx('', x)

  BoxOpen("flashing automatically","for %x% seconds")
  TimeDelay(x+3)

  ; Flash Notepad
  Run( 'Notepad.exe', '' )
  FlashWindowEx('~Notepad', x)
  TimeDelay(x)
  WinClose('~Notepad')
  Exit



Article ID:   W18351
Filename:   Flash Window.txt
File Created: 2011:04:11:08:26:36
Last Updated: 2011:04:11:08:26:36