Use keypress to trigger script

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
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.
Locked
User avatar
daviesg6
Posts: 49
Joined: Thu Nov 21, 2013 12:36 pm

Use keypress to trigger script

Post by daviesg6 » Thu Apr 17, 2014 9:28 am

I have created a form with multiple PowerShell scripts available to the user (primarily searches for AD objects). Each of these has the option to run and display on screen or export to file via buttons.

I would like to improve this by allowing users the option to hit a key (enter for example) to run the script. Is there a way I can do this? I know it is possible to use this option if there is a single button, but I can't work out how to do this for multiple options.

Is there a way to do this :?:

jvierra
Posts: 13882
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Use keypress to trigger script

Post by jvierra » Thu Apr 17, 2014 9:53 am

There can only be one default action per form. The enter key is assigned to the defined default.

You can handle all keys and detect the enter key and have it do anything you want but it has to be hand coded.

User avatar
daviesg6
Posts: 49
Joined: Thu Nov 21, 2013 12:36 pm

Re: Use keypress to trigger script

Post by daviesg6 » Thu Apr 17, 2014 9:57 am

jvierra wrote:There can only be one default action per form. The enter key is assigned to the defined default.

You can handle all keys and detect the enter key and have it do anything you want but it has to be hand coded.
Thanks, kind of figured that was the case but wanted confirmation. I'll leave it so the users have to use the mouse to hit the button they want to use.

Locked