Low Orbit Flux Logo 2 F

PowerShell How To Send Keystrokes

We are going to show you how to send keystrokes using PowerShell. There are many reasons you might want to do this. It is incredibly useful and it can save you a lot of time.

Here is one method that you can use to send keystrokes with PowerShell:


$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Untitled - Notepad')
$wshell.SendKeys('asdf')

You will probably want to send your keystrokes to a specific application. Before actually sending keystrokes you will want to activate the window that you want to send them to. This is done by specifying the title of the window. The above example will use AppActivate() to activate the application with the title ‘Untitled - Notepad’ which is the default title of a newly opened instance of notepad. Once you’ve activated the window you can send keystrokes to it.