Sunday, August 10, 2008

Getting a little GUI with PowerShell - WASP, the Windows Automation Snapin for PowerShell

CodePlex - Windows Automation Snapin for PowerShell

WASP

WASP is a PowerShell snapin for Windows Automation tasks like selecting windows and controls and sending mouse and keyboard events. We have automation cmdlets like Select-Window, Select-Control, Send-Keys, Send-Click, Get-WindowPosition, Set-WindowPosition, Set-WindowActive, Remove-Window ... etc.

Our goal is to enable you to accomplish most Windows GUI Automation scripting from inside PowerShell, without resorting to specialized (and expensive) scripting tools.

Just to be clear, don't expect any "click to record" functionality ... but do expect to be able to automatically tile windows, send mouse clicks and keystrokes, and in general, automate those tasks that you would normally not be able to do from a console." [Project description leached in full]

Windows Automation Snapin for PowerShell - automation cmdlets

  • Select-Window - pick windows by process name or window caption (with wildcard support)
  • Select-Control - pick controls by class and/or name and/or index (with wildcard support)
  • Send-Click - send mouse clicks (any button, with any modifier keys)
  • Send-Keys - Windows.Forms.SendKeys lets you send keys ... try this: Select-Window notepad | Send-Keys "%(ea)Testing{Enter}{F5}" (and for extra fun, try it with multiple notepad windows open).
  • Set-WindowActive - yeah, just activates the window
  • Set-WindowPosition - set any one of (or all of) top, left, width, height on a window ... or maximize/minimize/restore
  • Get-WindowPosition - get the position (kind-of redundant, actually, since the Window object has it's position as a property)
  • Remove-Window - closes the specified window

[Wikipage leached in full]

That's kind of an interesting project and I can see this being useful...

No comments: