WASP is a PowerShell snapin for Windows Automation tasks like selecting windows and controls and sending mouse and keyboard events. WASP has automation cmdlets like
Select-Window, Select-Control, Send-Keys, Send-Click, Get-WindowPosition, Set-WindowPosition, Set-WindowActive, Remove-Window … etc.
Its goal is to enable Windows GUI Automation scripting from inside PowerShell without resorting to specialized 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.
Download from releases, and extract into a PowerShell module directory (e.g., you can try, $env:PSModulePath -split ';' | Select-Object -First 1). Use Get-Module -ListAvailable -Name WASP | Import-Module to make its cmdlets available to the shell. Detailed instructions here: How to install WASP as module in PowerShell
- Choose your module install path
- Ensure DLL is in the WASP directory
- Copy WASP DLL to module path and unblock it
- Import new module
notepad.exe
explorer.exe
Select-Window | ft –auto
Select-Window notepad* | Set-WindowActive
Select-Window explorer | Select -First 1 | Remove-WIndow
notepad; notepad; notepad; notepad;
$i = 1;$t = 100; Select-Window notepad | ForEach { Set-WindowPosition -X 20 -Y (($i++)*$t) -Window $_ }
Select-Window notepad | Send-Keys "this is a test"
THE PROBLEM with sending keys like that is:
if there is no confirmation dialog because the file is unchanged, the Alt+N still gets sent
Select-Window notepad | Select -First 1 | Send-Keys "%{F4}%n"
Select-Window notepad | Select -First 1 | Remove-Window -Passthru | `
Select-ChildWindow | Send-Keys "n"
Select-Window notepad | Select -First 1 | kill
Select-Window notepad | Select -First 1 | Remove-Window -Passthru | `
Select-childwindow | select-control| select-control| select-control -title "Do&n't Save" | Send-Click
Select-Window notepad | Select -First 1 | Remove-Window -Passthru | `
Select-childwindow | select-control -title "Do&n't Save" -recurse | Send-Click
Select-Window devenv | Select-ChildWindow | Send-Click 10 10 -Double
Select-Window- Pick windows by process name or window caption (with wildcard support)Select-ChildWindow- Pick all owned windows of another window (e.g., dialogs, tool windows)Select-Control- Pick controls (children) of a specific window, by class and/or name and/or index (with wildcard support) -- NOTE: the "Window" can be specified as "-Window 0" to get all parentless windows, which includes windows, dialogs, tooltips, etc.… With -Window 0 this returns a true superset of the Select-Window output.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- Simply activates the windowSet-WindowPosition- Set any one of (or all of) top, left, width, height on a window … or maximize/minimize/restoreGet-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