Sign in to follow this  
Followers 0
MarcZ

AutoItX and PowerShell integration

9 posts in this topic

#1 ·  Posted (edited)

Good day.

I've been having some difficulties getting going with AutoItX.

What I am trying to do is to use AutoItX within PowerShell to automate some difficult GUI interactions in an application I have.

I am not trying to execute AU scripts but rather wish to programmatically call AutoItX function call inside a powershell script.

So far all documentation I have found shows the exact same:

1. Register the correct AutoItX DLL (by arch)

2. Create a "New-Object" and

3. Call the method needed.

And so far all the code samples I have found look the same,(e.g:This should simply launch an instance of notepad.)

<code>

$AutoIt = New-Object -ComObject AutoItX3.Control
$result = $AutoIt.Run("notepad.exe")

</code>

The problem is that this ".Control" is not available (though a "Control.Tasksymbol" is seen"

So my questions are:

1. How can I determine that the DLL is indeed registered in Windows?

2. What is the correct way to "make available" to powershell, the contained methods of AutoItX ?

3. Should/ should not ".Control" show up in the intellisense/autocomplete?

Thanks!

M.

Edited by MarcZ

Share this post


Link to post
Share on other sites



You should actually just use Jon's Powershell extension which is in your install of AutoIt at "C:\Program Files\AutoIt3\AutoItX\AutoItX3.PowerShell.dll" or the x86 program files if you have a 64 bit Windows.

Share this post


Link to post
Share on other sites

Yes, use the PowerShell interface, not the COM one - this handles all the x86/x64 problems automagically.  Just open PS, browse to the AutoItX folder and then do:

    # Import the module manfiest

    Import-Module .AutoItX3.psd1

    # Get the list of AutoItX cmdlets

    Get-Command *AU3*

    # Get detailed help for a particular cmdlet

    Get-Help Get-AU3WinText

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@MarkZ

Quick PS Example

CLS
# Import the module manfiest
Import-Module (${Env:ProgramFiles(x86)} + "\AutoIt3\Beta\AutoItX\AutoItX3.psd1")
I
nvoke-AU3Run("Notepad")

Wait-AU3WinActive("Untitled")

Send-AU3Key("I'm in notepad");

$winHandle = Get-AU3WinHandle("Untitled");

Sleep -Seconds 2

Close-AU3Win($winHandle)

# Get the list of AutoItX cmdlets
Get-Command *AU3*

# Get detailed help for a particular cmdlet
# Get-Help Get-AU3WinText
 

Rgds
ptrex

Edited by ptrex

Share this post


Link to post
Share on other sites

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  
Followers 0