隐藏弹出窗口,并启用父窗口
$signature = @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
public static extern bool SetWindowLongPtr(IntPtr hWnd, Int32 nIndex, Int64 dwNewLong);
"@
Function Show-Window{
Param( [parameter(Mandatory=$false, ValuefromPipeline = $false)] [String[]] [ValidateSet( "Hide", "Normal", "ShowMinimized", "Maximize", "ShowNoActivate", "Show", "Minimize", "ShowMinNoActive", "ShowNA", "Restore", "ShowDefault", "ForceMinimize")] $WindowState = "Normal",
[parameter(Mandatory=$false, ValuefromPipeline = $true)] [Int32] $ID = $PID
)
$showWindowAsync = Add-Type -memberDefinition $signature -name "Win32ShowWindowAsync" -namespace Win32Functions -passThru
switch($WindowState){
"Hide" {$WinStateInt = 0}
"Normal" {$WinStateInt = 1}
"ShowMinimized" {$WinStateInt = 2}
"Maximize" {$WinStateInt = 3}
"ShowNoActivate" {$WinStateInt = 4}
"Show" {$WinStateInt = 5}
"Minimize" {$WinStateInt = 6}
"ShowMinNoActive" {$WinStateInt = 7}
"ShowNA" {$WinStateInt = 8}
"Restore" {$WinStateInt = 9}
"ShowDefault" {$WinStateInt = 10}
"ForceMinimize" {$WinStateInt = 11}
default {$WinStateInt = 1}
}
$showWindowAsync::ShowWindowAsync( $ID, $WinStateInt)|Out-Null
}
Function Enable-Window{
Param( [parameter(Mandatory=$false, ValuefromPipeline = $true)] [Int32] $ID ,
$style,
$newValue
)
$SetWindowLongPtr = Add-Type -memberDefinition $signature -name "Win32SetWindowLongPtr" -namespace Win32Functions -passThru
$SetWindowLongPtr::SetWindowLongPtr( $ID, $style, $newValue)|Out-Null
}
弹出窗口,隐藏
Show-Window -ID 0x4023a -WindowState Hide
父窗口,启用
Enable-Window 0x40292 -16 0x17cf0000