NAME

Win32::AutoItX - Automate the Windows GUI using AutoItX

SYNOPSIS

use Win32::AutoItX;

my $a = Win32::AutoItX->new;

### AutoItX native methods ###

my $pid = $a->Run('calc.exe');

my $clipboard_text = $a->ClipGet;
$a->ClipPut("Win32::AutoItX rulez!");

my $color = $a->PixelGetColor(42, 42);

### Perlish methods ###

my $window = $a->get_window('Calculator');
$window->wait;
for my $control ($window->find_controls) {
    local $\ = "\n";
    print "Control $control";
    print "\thandle: ", $control->handle;
    print "\ttext: ", $control->text;
    print "\tx: ", $control->x, "\ty: ", $control->y;
    print "\twidth: ", $control->width, "\theight: ", $control->height;
}

my $button_2 = $window->find_controls('2', class => 'Button');
my $button_3 = $window->find_controls('3', class => 'Button');
my $button_plus = $window->find_controls('+', class => 'Button');
my $button_eq = $window->find_controls('=', class => 'Button');
my $result = $window->find_controls('0', class => 'Static');

$button_2->click;
$button_3->click;
$button_plus->click;
$button_3->click;
$button_2->click;
$button_eq->click;

print "23 + 32 = ", $result->text, "\n";

DESCRIPTION

Win32::AutoItX helps to automate the Windows GUI using the AutoItX COM interface. To use this module you have to install AutoIt v3 (https://www.autoitscript.com/autoit3/) or register the AutoItX COM/ActiveX component.

On the first constructor ("new") invoke it tries to initialize the COM library. To avoid issues with the security context don't import Win32::OLE module in the same script using use.

METHODS

new

$obj = Win32::AutoItX->new(%options)

creates a new instance of Win32::AutoItX object.

Available options:

debug

enables the debug mode (Win32::AutoItX will print additional information for debugging).

ole_warn

determines the behavior of the Win32::OLE module when an error happens. Please see "Warn" in Win32::OLE. Default is 3 (Carp::croak).

ole_cp

determines the codepage used by all translations between Perl strings and Unicode strings used by the OLE interface. Please see "CP" in Win32::OLE. Default is CP_UTF8.

debug

$debug_is_enabled = $obj->debug
$obj = $obj->debug($enable_debug)

if the argument is defined it enables or disables the debug mode and returns the object reference. Otherwise it returns the current state of debug mode.

list_windows

$hash_ref = $obj->list_windows($win_title)
$hash_ref = $obj->list_windows($win_title, $win_text)

returns a hash reference with $handler => $title elements. Optionally windows can be filtered by title and/or text.

get_window

$window = $a->get_window($title)
$window = $a->get_window($title, $text)

returns a Win32::AutoItX::Window object for the window with specified title and text (optionally).

AutoItX methods

This module also autoloads all AutoItX methods. For example:

$obj->WinActivate($win_title) unless $obj->WinActive($win_title);

Please see AutoItX Help file for documenation of all available methods.

ENVIRONMENT VARIABLES

AUTOITX_DEBUG

enables additional output to the STDOUT. Can be overwrited with debug option in the constructor ("new") or with method "debug".

SEE ALSO

Win32::AutoItX::Window
Win32::AutoItX::Control
AutoItX Help
https://www.autoitscript.com/autoit3/docs/
Win32::OLE

AUTHOR

Mikhail Telnov <Mikhail.Telnov@gmail.com>

COPYRIGHT

This software is copyright (c) 2017 by Mikhail Telnov.

This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.