Quantcast
Channel: Windows Automation Snapin for PowerShell
Viewing all 129 articles
Browse latest View live

New Post: No updates in three years?

$
0
0
Ah, appreciate the clarification.

That's why I tried pinging you over on Huddled Masses to try to get this figured out :) Btw, after I submitted the contact form it took me to a "the resource could not be found" page.

New Post: No updates in three years?

$
0
0
I should probably just take down that contact thing and explain you can just email my username at HuddledMasses.org (or use my username "Jaykul" (or email address at HuddledMasses) to IM me on AIM/Twitter/Facebook/Jabber/GTalk/MSN/Skype/etc).

New Post: No updates in three years?

$
0
0
Ah, appreciate the clarification.

That's why I tried pinging you over on Huddled Masses to try to get this figured out :) Btw, after I submitted the contact form it took me to a "the resource could not be found" page.

New Post: Manipulating ComboBox class

$
0
0
HI all

I am trying to use WASP to manipulate a drop down list box. I am able to navigate to the control which reports its class as a ComboBox. However I am unable to manipulate the control in any way. The available memebers are:
PS G:\> $db_combo | Get-Member


   TypeName: Huddled.Wasp.Control

Name             MemberType Definition
----             ---------- ----------
Activate         Method     System.Void Activate()
Close            Method     System.Void Close()
Equals           Method     bool Equals(System.Object obj), bool Equals(Huddled.Wasp.WindowHandle wnd)
GetChildren      Method     System.Collections.Generic.List[Huddled.Wasp.WindowHandle] GetChildren()
GetClassName     Method     string GetClassName()
GetHashCode      Method     int GetHashCode()
GetIsActive      Method     bool GetIsActive()
GetIsMaximized   Method     bool GetIsMaximized()
GetIsMinimized   Method     bool GetIsMinimized()
GetMainWindow    Method     Huddled.Wasp.Window GetMainWindow()
GetParent        Method     System.IntPtr GetParent()
GetParentOrOwner Method     System.IntPtr GetParentOrOwner()
GetPosition      Method     System.Drawing.Rectangle GetPosition()
GetProcessId     Method     int GetProcessId()
GetType          Method     type GetType()
GetWindowText    Method     string GetWindowText()
IsAppWindow      Method     bool IsAppWindow(), bool IsAppWindow(bool includeToolWindows)
Maximize         Method     System.Void Maximize()
Minimize         Method     System.Void Minimize()
PointToScreen    Method     System.Drawing.Point PointToScreen(System.Drawing.Point origin), System.Drawing.Point PointToScreen(int X, int Y)
Restore          Method     System.Void Restore()
SetPosition      Method     System.Void SetPosition(System.Drawing.Rectangle value), System.Void SetPosition(int x, int y, int width, int height)
SetSize          Method     System.Void SetSize(int width, int height)
ToString         Method     string ToString()
Class            Property   System.String Class {get;}
Handle           Property   System.IntPtr Handle {get;set;}
Title            Property   System.String Title {get;}
How do I find out what items populate the drop down list and how to select one of them?

New Post: Manipulating ComboBox class

$
0
0
I am not sure -- you should be able to either check the Title property or call .GetWindowText,() on it to see the current value. I can't remember a way to get a list using the Win32 APIs right now other than that, and using SendKeys (up/down, or just type the name you want). to cycle through them.

With the WASP2 module that I've been working on you can access it using UIAutomation which will get you the list, and let you specify the one you want ... I guess I really should put that code on this page as a beta so people can use it .. I'm just frustrated because it's hard to make it "powershelly"

Anyway, just as an example, on the PuTTY Configuration Window, I can set the Parity like so:
$Combo= Select-UIElement -Process Putty | Select-UIElement Parity -Type ComboBox 

# List out the items (because I was scripting interactively)$Combo | Select-UIElement -Type ListItem  -Recurse # | Select-Object -Expand Name# Now pick one of them and select it:$Combo | Select-UIElement "Even" -Type ListItem  -Recurse | Invoke-SelectionItem.Select
Incidentally, you see there part my problem with this vs. the current WASP: that whole "Invoke-SelectionItem.Select" thing is awkward...

New Post: Manipulating ComboBox class

$
0
0
I've tried using SendKeys but it does not seem to work reliably. It might be to do with the fact that I am trying to automate a Uniface GUI and it is behaving in a none standard way. Though WASP does correctly identify the elements in the GUI which gave me some hope initially.

How can I try your new WASP2 code? Can you point me to some setup instructions.

Thanks!

Updated Wiki: Documentation

$
0
0
The WASP project is in the midst of a long drawn out transition from being a binary module to being a script module. I'm also working on a Packaging module, and using the WASP project as the guinea pig. For that, I need a Release Feed.

New Post: Download File : Save & open button

$
0
0
Hello,
When I download a file, the file download popup appears.
I can do a send-click on the cancel button but not Save or Open.
All other features work.

I have a french version.
$IE = New-Object -comObject InternetExplorer.Application.1 ; $IE.visible = $True 
$IE.Navigate("http://www.XXXX.fr/request?type=VIE&date=20130326&ext=zip")
Select-Window iexplore | Remove-Window -Passthru |Select-ChildWindow | Select-Control

Title
-----
...
Ou&vrir
En&registrer
Annuler
...

Select-Window iexplore | Remove-Window -Passthru |Select-ChildWindow | Select-Control -title "En&registrer"

Title
-----
En&registrer

Select-Window iexplore | Remove-Window -Passthru |Select-ChildWindow | Select-Control -title "En&registrer" -recurse |send-click
Regards,

New Post: Download File : Save & open button

$
0
0
I'm hoping someone who's tried that before will pipe up, but if you're getting the frame notification, the simplest way to deal with those is with the hotkey for the button you want: %S (Alt+S) for Save, or %O (Alt+O) for Open:
$IE= New-Object -comObject InternetExplorer.Application.1 ; $IE.visible =$True$IE.Navigate("https://wasp.codeplex.com/downloads/get/55849")
Start-Sleep 3
Select-Window iexplore | Select-Control -Class "Frame Notification Bar" | Send-Keys "%S"

New Post: Download File : Save & open button

$
0
0
Thank's for you answer.

I tried...sleep.
a = Select-Window iexplore | Remove-Window -Passthru |Select-ChildWindow |set-windowactive ; sleep 3 ; $a |Send-Keys "%r"

New Post: Download File : Save & open button

$
0
0
So is it working for you?

For what it's worth, the only reason I used Start-Sleep is because in my example, .Navigate() is going to a page that redirects to the actual download, so I had to wait for the download to start and show up on the notification.

New Post: Where's the documentation?!

$
0
0
I may not be the smartest guy in the room... but I'm not the dumbest. The documentation tab is completely void of anything. The examples don't really explain HOW to use it... just leads you by the nose on a couple of novel examples.

I started out very simply and it just isn't working. Opened notepad manually.
Select-Window -ProcessName "notepad" | Set-WindowActive | Send-Click -Button Right
The notepad window comes to the foreground but it does not right click. If it did right click I would get a menu box that would pop up.

I tried :
Select-Window -ProcessName "notepad" | Set-WindowActive | Send-Click -Button Left
Again it comes to the foreground but does not left click. If it did then the text I had highlighted from before would become un-highlighted as it clicked somewhere else.

Tried giving it a position thinking it wasn't anywhere in the window.
Select-Window -ProcessName "notepad" | Set-WindowActive | Send-Click -Left 800-Top 425 -Button Left
My desktop resolution is 1600x900 so it should be somewhere near the center which would be in the middle of my text document. Same behavior. I tried throwing in some start-sleeps and that didn't seem to make a difference.

Send-Keys seems to work
Select-Window -ProcessName "notepad" | Set-WindowActive | Send-Keys "derp"
It replaces what I had highlighted with derp which is exactly what i expected.

All I'm trying to do is simply send a left click, or hold left click for a duration of time, on an active window. It seems really simple but I don't get why it's not working.

Please advise or point me to some real documentation I can refer to.

Thanks!

New Post: Where's the documentation?!

$
0
0
Yeah, sorry ... I've been playing with the UIAutomation script version of this and don't want to write documentation for this version because the new one is so different.

First off: I HIGHLY recommend avoiding clicks for UI Automation. They're unreliable because they have to have coordinates. Some windows won't respond to a click at 0,0 so you have to specify coordinates just to get them to work at all.

The problem you're having has to do with which element you're targeting and the exact coordinates being clicked. Send-Click targets the specific window/control that has been selected, and defaults to the 0, 0 coordinates, so your click is basically hitting the window border where nothing happens when you click or double-click.

The following works:
$edit= Select-Window notepad | Select-Control Edit 
$edit | Send-Keys "This is a test of the clickity-click system"$edit | Send-Click -DoubleClick -top 10 -Left 10
The click selects the first word. It works because the click is going to the Edit control, and is offset at 10, 10 from the top left corner of the window. If you don't offset, the click goes to the border of the edit control, which still doesn't do anything. My guess is that in your example, 800, 425 is too far and going right off the window, but probably wouldn't work without targeting the edit control anyway.

But again, I wouldn't use clicks if I can avoid it. Send the keystrokes or move-window, etc when you can.

I am currently working on a Module Packaging system for PoshCode.org, but when that's finished, I will prioritize getting the next version of the UI Automation script version of WASP

New Comment on "Some Usage Examples"

$
0
0
Hey, 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.

New Post: Manipulating ComboBox class

$
0
0
I just started using the WASP2 project recently...this is how i set it up:
  1. Download the UI Automation as well as the Reflection and Autoload modules
  2. Rename the files as:
Autoload.psm1"
Reflection.psm1"
UIAutomation.psm1"

(I removed the file version numbers from the example so that these instructions don't become out of date with the next release of any module)

Load the modules with the commands:
Import-Module .\Autoload.psm1
Import-Module .\Reflection.psm1
Import-Module .\UIAutomation.psm1
I hope this helps.

-Scott

New Post: Manipulating ComboBox class

$
0
0
Yeah, I'm working on a packaging module that will resolve dependencies so that I can distribute it easier :)

New Post: Where's the documentation?!

$
0
0
Send-Keys or Send-Click are both fine for what I want to do; so I'll try Send-Keys as you advise.

Again it works fine with Notepad but I don't really need to manipulate Notepad. I have game window that I want to send a key to.
Import-Module .\WASP.dll

Select-Window PS2 | Set-WindowActive

$PS2_Client = Select-Window PS2 | Set-WindowActive
That all seems to work fine there. Module imports, I can select the window and bring it to the foreground with Set-WindowActive.
Now lets try to send it some keys.

I bound the L key in the game to a simple function. If I interactively hit the L key on my keyboard it fires the main gun. However if I try this command... does nothing.
$PS2_Client = Select-Window PS2| Set-WindowActive


$PS2_Client | Send-Keys "LLLL"


The game window comes to the foreground .... and it's like stuck.... Click the mouse manually and it snaps back and operates interactively but it doesn't shoot the main gun.

New Post: Where's the documentation?!

$
0
0
You may need to select a child control and send keystrokes to that.

New Post: Where's the documentation?!

$
0
0
I feel like I'm missing a huge, fundamental, part of how this all works.

For example:
Select-Control - pick controls (children) of a specific window, by class and/or name and/or index (with wildcard support)

What are the classes?
How do I know one of them is Select-Control Edit other than someone telling me that is one of them?
How do I know which classes are available to a given program window object?
How do I figure out which child control to interface with?

Get-Help gives me some info but not ALL the info I need. Doesn't even mention "edit" or any other classes or how to even call a class:
PS C:\Temp\WASP> get-help Select-Control

NAME
    Select-Control

SYNTAX
    Select-Control [[-Index] <Int32>] -Window <WindowHandle> [-Title <String>] [-Recurse] [-Verbose] [-Debug] [-ErrorAc
    tion <ActionPreference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>]
    [-OutVariable <String>] [-OutBuffer <Int32>]
    Select-Control [-Class] <String> [[-Title] <String>] [[-Index] <Int32>] -Window <WindowHandle> [-Recurse] [-Verbose
    ] [-Debug] [-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-Warnin
    gVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]

New Post: Where's the documentation?!

$
0
0
The help is woefully lacking because the cmdlets are compiled (not script), I need to write MAML help files (which is still a pain in PowerShell) rather than just comment-based help. Anyway, the fact is, there's no way to know the answer to that.

Classes are created by programmers. There's a certain subset of them which are common ( "Edit" for instance), but there's an infinite number of possibilities (that's why there's not an enum tab-complete list). Same goes for Window handles, of course -- except worse: those are relatively random numbers generated by the system.

There's no way for me to know what classes are available in your app, that's why when you pipe a window (or a control) to Select-Control, it shows you all the immediate child items, by default. Normally, you just keep adding another | Select-Control ... until you find something that looks right.

The best way, perhaps, is to get out Spy++ or something like it and use it to CLICK on the control you want to interact with and find it's class...

Commercial tools come with recorders that will track each click and set it all up for you. There's actually another PowerShell UIAutomation project on CodePlex which claims to be able to do that (I haven't tried it).
Viewing all 129 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>