northben
northben

Reputation: 5588

Can PowerShell handle keyboard events? As a macro programming language, or AutoHotKey replacement

I use AutoHotKey a lot, and I really like it. But even after several years of using it, the syntax is still cumbersome. Is it possible to create keyboard macros with PowerShell instead? So when I type Alt-1, my email address is entered on the screen, etc.

Upvotes: 1

Views: 1999

Answers (1)

Danny Tuppeny
Danny Tuppeny

Reputation: 42343

I doubt you can do this in native PowerShell/Cmdlets, but since you can call out to Windows APIs, you should be able to do it.

I found these two links for keyloggers in PowerShell, which need to do the same sort of thing (read keyboard without having focus), which both work by compiling some C# to call Windows APIs.

Not a nice solution, but you can probably wrap it up and put a nice API over it:

http://code.google.com/p/nishang/source/browse/trunk/Keylogger.ps1 http://zokoloco.blogspot.co.uk/2011/03/key-logger-for-special-project-using.html

Upvotes: 2

Related Questions