Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Async = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
- $Type = Add-Type -MemberDefinition $Async -name Win32ShowWindowAsync -namespace Win32Functions -PassThru
- $hwnd = (Get-Process -PID $pid).MainWindowHandle
- if($hwnd -ne [System.IntPtr]::Zero){
- $Type::ShowWindowAsync($hwnd, 0)
- }
- else{
- $Host.UI.RawUI.WindowTitle = 'hideme'
- $Proc = (Get-Process | Where-Object { $_.MainWindowTitle -eq 'hideme' })
- $hwnd = $Proc.MainWindowHandle
- $Type::ShowWindowAsync($hwnd, 0)
- }
Advertisement
Add Comment
Please, Sign In to add comment