My standard demo:

## Open a couple windows
## list the windows
Select-Window | ft –auto
## Activate Notepad
Select-Window notepad* | Set-WindowActive
## Close Explorer
Select-Window explorer | Select -First 1 | Remove-WIndow
## Run a few more copies of notepad
notepad; notepad; notepad; notepad;
## Move them around so we can see them all ... (Note the use of foreach with the incrementation)
$i = 1;$t = 100; Select-Window notepad | ForEach { Set-WindowPosition -X 20 -Y (($i++)*$t) -Window $_ }
## Put some text into them ...
Select-Window notepad | Send-Keys "this is a test"
## Close the first notepad window by pressing ALT+F4, and pressing Alt+N
## In this case, you don't have to worry about shifting focus to the popup because it's modal
## 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"
## Close the next notepad window ... 
## By asking nicely (Remove-Window) and then hitting "n" for "Don't Save"
## If there are no popups, Select-ChldWindow returns nothing, and that's the end of it
Select-Window notepad | Select -First 1 | Remove-Window -Passthru | 
   Select-ChildWindow | Send-Keys "n"
## Close the next notepad window the hard way 
## Just to show off that our "Window" objects have a ProcessID and can be piped to kill
Select-Window notepad | Select -First 1 | kill
## A different way to confirm Don't Save (use CLICK instead of keyboard)
## Notice how I dive in through several layers of Select-Control to find the button?
## This can only work experimentally: 
## use SPY++, or run the line repeatedly, adding "|Select-Control" until you see the one you want
Select-Window notepad | Select -First 1 | Remove-Window -Passthru | 
   Select-childwindow | select-control| select-control| select-control -title "Do&n't Save" | Send-Click
## But now we have the new -Recurse parameter, so it's easy.  Just find the window you want and ...
Select-Window notepad | Select -First 1 | Remove-Window -Passthru | 
   Select-childwindow | select-control -title "Do&n't Save"  -recurse | Send-Click

My favorite use: re-dock all visual studio tool windows

## NOTE: 0, 0 is the resize corner, so you need to specify X,Y coordinates for the click:
Select-Window devenv | Select-ChildWindow | Send-Click 10 10 -Double 

Last edited Jan 21, 2009 at 3:44 PM by Jaykul, version 2


dannyelko Apr 12, 2013 at 12:46 PM 

I know its a stupid question but, what is the name for the "space-button"
I tried space,spacebutton,spacekey.spacebar none of them work. backspace works.

Thanks for any answers.

adamgovuk Oct 13, 2011 at 9:09 PM 
WASP seriously ROCKS...managed to automate sending a report generated by powershell, via outlook web access, all using WASP. Thank you so much for allowing easy GUI automation of windows. Have found on older systems a lot of start-sleep is needed to delay the clicks as the example Send-Keys "%{F4}%n" works fine on my home quad-core machine but at work...on a work machine, I had to change this to:-
Select-Window notepad | Set-WindowActive | Send-Keys "%{F4}"
Start-Sleep -Milliseconds 1500
Select-Window notepad | select-childwindow | Set-WindowActive | Send-Keys "{TAB}"
Start-Sleep -Milliseconds 1500
Select-Window notepad | select-childwindow | Set-WindowActive | Send-Keys "{ENTER}"
As it did not always close the notepad window....but all in all this is one amazing snapin!

powershelluser Mar 29, 2010 at 9:49 AM 

Great work, I have a script which can install setup by calling abcd.exe file, And this done without human interaction using WASP. Now i have a small problem. I want to use this script wrapped into .msi so that i don't have to use .exe every time. Do you know how to do this. its urgent Please help me. Can powershell create .msi file wrapping the script along with .exe, So that when i double click .msi i automatically runs the script and install abcd.msi without human interaction.

schmeckendeugler Nov 18, 2009 at 9:04 PM 
Oh- I forgot to add: Your WASP stuff appears to be the key to building my dream app! So, I hope I have time in the future to begin working on this.


schmeckendeugler Nov 18, 2009 at 9:03 PM 
Hi! I have a dream app in mind that I basically feel should be part of the standard windows operating system. Since it is not, I have begun researching how to do it through powershell. Let me briefly describe what I want. I think there should be a keystroke; perhaps a "WindowKey + Something", that:

1. Launches apps specified in some configuration options, if they are not already running;
2. Positions them at exactly the x/y coordinates, and with the size indicated, also set in some configuration options area.

I would find such a thing immensely helpful. Just imagine if you could, with a single keystroke, launch your e-mail, browser, a command prompt, your IM, or whatever it is you standardly run on a daily basis, and they all are exactly where you expect them.

slagment Aug 5, 2009 at 10:24 AM 
WASP is great, thank you.

I would like to see a list of the special keys, like pagedown, arrows, etc. I need to send a window the Page Down Key, and I'm not sure what to type. This information maybe available elsewhere, but here would be handy.


command_liner Jan 26, 2009 at 11:26 PM 
Interesting standard demo.
But the minimalist example
## Notepad
## Activate Notepad
Select-Window notepad* | Set-WindowActive
## Put some text into them ...
Select-Window notepad | Send-Keys "this is a test"

Launches Notepad and then does exactly NOTHING! At least on my system.
Running the full demo puts up 5 windows, and puts text in 2 of them.

My system is XP SP2 updated as of yesterday. Lots of Dev tools from MS
including VS 2008 with .NET 3.5

One example of successful usage of each command would be very helpful.
I have read the source and understand your approach, but so far WASP is
not doing much.