Product, version and build: 2019 5.6.159.0
32 or 64 bit version of product: 64
Operating system: Windows 10 1809
32 or 64 bit OS: 64
I am wondering if it is possible to deploy a powershell form executable that can detect if the CTRL button was held when launched. I am looking to have it perform a different task at startup if the CTRL button was held. So far I have tried keydown and keypress functions, but neither seem to work.
Basically my form gives users the option to select a database connection for a separate program. Once they select it and click the button, the form launches the application with the database settings, then the form plugs in a "first run" registry entry, and closes the form. The next time the form is launched it checks for that "first run" entry, and just runs the separate program without showing the database options.
I'd like to allow the user to hold CTRL while launching to re-enable the database selection. Is that possible?
Possible for a form to detect a key press before launch
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Possible for a form to detect a key press before launch
[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Possible for a form to detect a key press before launch
You can use the following to check if the Ctrl key is pressed:
Although, it helps to see the script itself to see what you are trying to accomplish.
Code: Select all
([System.Windows.Forms.Control]::ModifierKeys -band [System.Windows.Forms.Keys]::Control) -ne 0
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.