iNNOKENTIY21
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Код: function Set-TopMost { param ( [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [Alias('MainWindowHandle')]$hWnd = 0 ) $signature = @" [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,int Y, int cx, int cy, uint uFlags); static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); const UInt32 SWP_NOSIZE = 0x0001; const UInt32 SWP_NOMOVE = 0x0002; const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE; public static void SetTopMost (IntPtr fHandle) { SetWindowPos(fHandle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); } "@ Add-Type -MemberDefinition $signature -Name Win32 -Namespace API if ($hWnd -ne 0) { [API.Win32]::SetTopMost($hWnd) } } $path = 'c:\Program Files\JPEGView64\JPEGView.exe' $hWnd = Start-Process -FilePath $path -ArgumentList $args -PassThru Start-Sleep -Milliseconds 500 $hWnd | Set-TopMost | |