This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$code = @" | |
[DllImport("user32.dll", SetLastError = true)] | |
public static extern int GetWindowLong(IntPtr hWnd, int nIndex); | |
[DllImport("user32.dll")] | |
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); | |
[DllImport("user32.dll")] | |
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); | |
"@ | |
Add-Type -MemberDefinition $code -Name Win32Util -Namespace System | |
$WS_VISIBLE = 0x10000000 | |
$WS_EX_TOOLWINDOW = 0x00000080 | |
$WS_EX_APPWINDOW = 0x00040000 | |
$SW_HIDE = 0 | |
$SW_SHOW = 5 | |
$MainWindowHandle = (Get-Process -Name notepad)[0].MainWindowHandle | |
$style = [System.Win32Util]::GetWindowLong($MainWindowHandle,$GWL_STYLE) | |
$style = $style -band ( -bNOT ($WS_VISIBLE)) | |
$style = $style -bor $WS_EX_TOOLWINDOW | |
$style = $style -band ( -bNOT ($WS_EX_APPWINDOW)) | |
[System.Win32Util]::ShowWindow($MainWindowHandle, $SW_HIDE) | |
[System.Win32Util]::SetWindowLong($MainWindowHandle,$GWL_STYLE, $style) | |
[System.Win32Util]::ShowWindow($MainWindowHandle, $SW_SHOW) | |
[System.Win32Util]::ShowWindow($MainWindowHandle, $SW_HIDE) |
Reference(s):
http://stackoverflow.com/questions/7219063/win32-how-to-hide-3rd-party-windows-in-taskbar-by-hwnd
No comments:
Post a Comment