Triggering taskbar button flash from batch file?

后端 未结 1 539
一个人的身影
一个人的身影 2020-12-31 01:10

Is it possible to trigger Windows\' \"flash the task bar button X times or until the window comes to the foreground\" behavior from a batch file? I\'m trying to call the us

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 01:38

    It is very easy to do using a very simple external *.exe. It simply has to call the FlashWindowEx function of the Windows API.

    This is a sample Delphi console application:

    program flashwnd;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils, Windows;
    
    var
      OldTitle, UniqueTitle: string;
      h: HWND;
      c: cardinal;
      fwi: TFlashWInfo;
    
    begin
    
      try
        h := GetConsoleWindow();
    
        c := 10;
        if ParamCount = 1 then
          c := StrToInt(ParamStr(1));
    
        FillChar(fwi, sizeof(fwi), 0);
        fwi.cbSize := sizeof(fwi);
        fwi.hwnd := h;
        fwi.dwFlags := FLASHW_ALL;
        fwi.uCount := c;
        fwi.dwTimeout := 0;
        FlashWindowEx(fwi);
      except
        on E: Exception do
          Writeln(E.ClassName + ': ' + E.Message);
      end;
    end.
    

    Simply call it like

    flashwnd
    

    to flash the current console window ten times. Call

    flashwnd 27
    

    to flash the window 27 times.

    0 讨论(0)
提交回复
热议问题