zoukankan      html  css  js  c++  java
  • 显示、隐藏 PowerShell

    以下是一个快速实现该需求的 module。只要将以下代码复制粘贴到 DocumentsWindowsPowerShellPackagesPowerShellPowerShell.psm1 即可。

    $script:showWindowAsync = Add-Type memberDefinition @"
    [DllImport("user32.dll")]
    public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
    "@ -name "Win32ShowWindowAsync" -namespace Win32Functions passThru
    
    function Show-PowerShell() {
    $null = $showWindowAsync::ShowWindowAsync((Get-Process id $pid).MainWindowHandle, 10)
    }
    
    function Hide-PowerShell() {
    $null = $showWindowAsync::ShowWindowAsync((Get-Process id $pid).MainWindowHandle, 2)
    }

    现在,您可以用这段代码来显示或隐藏 PowerShell:

    Add-Module PowerShell
    # Minimize PowerShell
    Hide-PowerShell
    sleep 2
    # Then Restore it
    Show-PowerShell

    from:http://blog.vichamp.com/powershell/2014/06/23/show-powershell-hide-powershell/

        http://technet.microsoft.com/zh-cn/magazine/ms633548.aspx

  • 相关阅读:
    7.6实战练习
    构造方法的主要应用
    6.0字符串String
    数组冒泡排序
    数组(二维数组)
    5.1数组(一维部分)
    4个方位的三角形和菱形
    4.3循环语句
    控制台输入输出
    4 java语句 4.2条件语句
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/3817912.html
Copyright © 2011-2022 走看看