Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -Name Window -Namespace Console -MemberDefinition '
- [DllImport("Kernel32.dll")]
- public static extern IntPtr GetConsoleWindow();
- [DllImport("user32.dll")]
- public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
- '
- function Show-Console {
- $consolePtr = [Console.Window]::GetConsoleWindow()
- #5 show
- [Console.Window]::ShowWindow($consolePtr, 5)
- }
- function Hide-Console {
- $consolePtr = [Console.Window]::GetConsoleWindow()
- #0 hide
- [Console.Window]::ShowWindow($consolePtr, 0)
- }
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- $Form = New-Object System.Windows.Forms.Form
- $showButton = New-Object System.Windows.Forms.Button
- $showButton.Text = 'ShowConsole'
- $showButton.Top = 10
- $showButton.Left = 10
- $showButton.Width = 100
- $showButton.add_Click({Show-Console})
- $form.controls.Add($showButton)
- $hideButton = New-Object System.Windows.Forms.Button
- $hideButton.Text = 'HideConsole'
- $hideButton.Top = 60
- $hideButton.Left = 10
- $hideButton.Width = 100
- $hideButton.add_Click({hide-Console})
- $form.controls.Add($hideButton)
- $Form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement