Jump to content
Sign in to follow this  
Jon

Beta - AutoItX3_PS.dll (PowerShell Cmdlets)

Recommended Posts

Jon

I've added these experimental PowerShell Cmdlets to the beta download. 

To use open PowerShell ISE:

Import-Module "C:\Program Files\AutoIt\Beta\AutoItX\AutoItX3_PS.dll"

Wait-AU3WinActive -Title "Untitled - Notepad"

You will need to specify "C:Program Files (x86)" if you have a 64bit system.

It should work with PowerShell v2.0 or v3.0 - although it's in a very early stage yet.

Current CmdLets Implemented

Get-AU3ErrorCode
Initialize-AU3
Set-AU3Option
Send-AU3Key
Show-AU3WinActivate
Close-AU3Win
Get-AU3WinText
Get-AU3WinTitle
Close-AU3Win
Wait-AU3Win
Wait-AU3WinActive
Wait-AU3WinClose
Wait-AU3WinNotActive

Share this post


Link to post
Share on other sites
Jon

I'm going to use Parameter Sets to allow a lot of the Win functions to either accept Title/Text paramters or a proper window handle (HWND) that can be obtained from Get-WinHandle (next beta).

PS> Get-Help Wait-AU3WinClose

NAME
    Wait-AU3WinClose
    
SYNTAX
    Wait-AU3WinClose [-Title] <string> [[-Text] <string>] [[-Timeout] <int>]  [<CommonParameters>]
    
    Wait-AU3WinClose [-Handle] <IntPtr> [[-Timeout] <int>]  [<CommonParameters>]

The window handle will be treated as the .NET IntPtr type:

$handle = Get-AU3WinHandle -Title "Untitled - Notepad"

$handle.GetType()

IsPublic IsSerial Name                                     BaseType                                                     
-------- -------- ----                                     --------                                                     
True     True     IntPtr                                   System.ValueType

This will be far easier than trying to shoe-horn handles into strings.

Share this post


Link to post
Share on other sites
Richard Robertson

I never really understood why you put handles into strings instead of a wide-enough integer anyway. But then again, AutoItX was always just a side project.

Share this post


Link to post
Share on other sites
Jon

AutoIt didn't work with real handles when I first made AutoItX - handles were strings in there too.  AutoItX is mostly is simple wrapper around the AutoIt functions so is a symptom of the time it was developed and then never updated.

Share this post


Link to post
Share on other sites
Jon

I think the hardest part of this is mapping the AutoIt names to the PowerShell approved verbs list. 

http://msdn.microsoft.com/en-us/library/windows/desktop/ms714428%28v=vs.85%29.aspx

Some are fairly easy, like Get-AU3WinHandle. But the closest I can find for WinExists is Assert-AU3WinExists.  At least they are really easy to rename and alias. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×