Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 546

PowerShell GUIs • Close form on Escape Key

$
0
0
To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
Operating system: Windows 10
PowerShell version(s): 5.1

I am trying to close a form when the escape key is pressed. I've tried the below events with no success:

Code:

$frmAddAccount_KeyDown=[System.Windows.Forms.KeyEventHandler]{if ($_.KeyCode -eq 'Escape'){$frmAddAccount.Close()}}$frmAddAccount_KeyUp=[System.Windows.Forms.KeyEventHandler]{if ($_.KeyCode = 'Escape'){$frmAddAccount.Close()}}$frmAddAccount_KeyPress = [System.Windows.Forms.KeyPressEventHandler]{if ($_.KeyCode = 'Escape'){$frmAddAccount.Close()}}

Any help would be greatly appreciated

Statistics: Posted by supportMIB — Wed Feb 28, 2024 8:08 am



Viewing all articles
Browse latest Browse all 546

Trending Articles