-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStop-FlashingEQTaskbarButtons.ps1
More file actions
141 lines (120 loc) · 4.28 KB
/
Stop-FlashingEQTaskbarButtons.ps1
File metadata and controls
141 lines (120 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#Forces EQ taskbar buttons to flash continuously and then stops them. If the button has finished flashing, it'll will glow orange continuously and cannot be stopped.
#https://learn-powershell.net/2013/08/26/make-a-window-flash-in-taskbar-using-powershell-and-pinvoke/
Add-Type -TypeDefinition @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
public class Window
{
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 uCount;
public UInt32 dwTimeout;
}
//Stop flashing. The system restores the window to its original state.
const UInt32 FLASHW_STOP = 0;
//Flash the window caption.
const UInt32 FLASHW_CAPTION = 1;
//Flash the taskbar button.
const UInt32 FLASHW_TRAY = 2;
//Flash both the window caption and taskbar button.
//This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
const UInt32 FLASHW_ALL = 3;
//Flash continuously, until the FLASHW_STOP flag is set.
const UInt32 FLASHW_TIMER = 4;
//Flash continuously until the window comes to the foreground.
const UInt32 FLASHW_TIMERNOFG = 12;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
public static bool FlashWindow(IntPtr handle, UInt32 timeout, UInt32 count)
{
IntPtr hWnd = handle;
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.hwnd = hWnd;
fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
fInfo.uCount = count;
fInfo.dwTimeout = timeout;
return FlashWindowEx(ref fInfo);
}
}
"@
#https://www.displayfusion.com/ScriptedFunctions/View/?ID=42d44f29-df41-4c4e-872b-fa5181551cf2
Add-Type -TypeDefinition @"
using System;
using System.Drawing;
using System.Runtime.InteropServices;
// The 'windowHandle' parameter will contain the window handle for the:
// - Active window when run by hotkey
// - Window Location target when run by a Window Location rule
// - TitleBar Button owner when run by a TitleBar Button
// - Jump List owner when run from a Taskbar Jump List
// - Currently focused window if none of these match
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
ScriptHelper.EnumWindows(EnumWindowsCallback);
}
public static bool EnumWindowsCallback(IntPtr windowHandle, IntPtr lParam)
{
ScriptHelper.DisableWindowFlash(windowHandle);
return true;
}
}
public static class ScriptHelper
{
public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
//Stop flashing. The system restores the window to its original state.
public const UInt32 FLASHW_STOP = 0;
[StructLayout(LayoutKind.Sequential)]
private struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 uCount;
public UInt32 dwTimeout;
}
public static bool EnumWindows(EnumWindowsProc enumProc)
{
return EnumWindows(enumProc, IntPtr.Zero);
}
public static bool DisableWindowFlash(IntPtr windowHandle)
{
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.hwnd = windowHandle;
fInfo.dwFlags = FLASHW_STOP;
fInfo.uCount = 0;
fInfo.dwTimeout = 0;
return FlashWindowEx(ref fInfo);
}
}
"@
$handles = (Get-Process -Name eqgame)| Select-Object -ExpandProperty MainWindowHandle
foreach ($handle in $handles) #Flash all EQ Windows
{
[window]::FlashWindow($handle,150,0)
}
foreach ($handle in $handles) #Stop all flashing EQ Windows
{
#[DisplayFusionFunction]::Run($handle) #This seems to hang
[ScriptHelper]::DisableWindowFlash($handle)
}
#Other links
#https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-flashwinfo?redirectedfrom=MSDN
#https://stackoverflow.com/questions/21987/flashwindowex-flashw-stop-still-keeps-taskbar-colored