简体   繁体   中英

How to minimize powershell form after button click?

It doesn't matter if it is hidden or if it is minimized I just don't want it to be viewable to the user.

Pertinent Code:

$Login_Load={

}
$buttonENTER_Click = {
    $newuser = $username.Text
    $newpass = $password.Text
    GoTo_Run $newpass $newuser
}

Things I have tried: I have used the Set-WindowState Cmdlet but that hasn't worked for me either.

(Get-Process -Name processnameofform).MainWindowHandle | foreach {Set-WindowStyle FORCEMINIMIZE $_}

$Login.Hide

$Login.WindowState("Minimize")

FormWindowState is an enumeration

Assuming that $Login is your Form:

$Login.WindowState = [System.Windows.Forms.FormWindowState]::Minimized

or

$Login.WindowState = 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM