Answer the question
In order to leave comments, you need to log in
PowerShell and hotkeys, use inside a script, how?
Colleagues, tell me how you can process hot keys inside the Powershell script, when the script is running (creating your own) n.r. we run the script, press ctrl + 1 and we have some action (previously provided for by us), i.e. we need to catch hotkeys in the script, how can this be done?
I will supplement the question with an example: there is a user who works with text, and he needs to insert some permanent pieces of text, there are a lot of these pieces, I would like to insert these pieces on hot keys. those. we form a file with pieces or generally stuff them into variables, and then we call the specific piece of text we need at the moment via a hotkey in the active window (not a power window, but programs).
Answer the question
In order to leave comments, you need to log in
need more info. describe the scenario of using this functionality in more detail.
So far, I could only come up with this: we run the script, it gives out a menu and we can select menu items with hot keys. but there is no need to intercept hotkeys. it can simply be made to respond to characters entered:
----MY MENU----
1. Press 1 for this option
2. Press 2 for this option
Q. Press Q to quit
You misunderstand how hotkeys work.
When you press a combination of any keys, an event is generated, which Nikolay Petyukh gave a link to work with.
This event is passed to the active window. In the case of the script, this window simply does not exist.
You can handle user input (if the launch is interactive) or system events available to all processes on the system.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question