NAME
Win32::AutoItX::Control - OO interface for Window Controls
SYNOPSIS
use Win32::AutoItX;
my $a = Win32::AutoItX->new;
my $pid = $a->Run('calc.exe');
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::Control provides an object-oriented interface for AutoItX methods to operate with Window Controls.
METHODS
new
$control = Win32::AutoItX::Control->new(
$autoitx, $window_title, $window_text, $control_id
)
creates the control object.
listview
$listview = $control->listview()
returns a Win32::AutoItX::Control::ListView object for the control.
treeview
$treeview = $control->treeview()
returns a Win32::AutoItX::Control::TreeView object for the control.
click
$control->click()
$control->click($button, $clicks, $x, $y)
sends a mouse click command to a given control. $button
is the button to click: "left" (by default), "right" or "middle". $clicks
is the number of times to click the mouse (default is 1). $x
and $y
is the position to click within the control (default is center).
Note: Some controls will resist clicking unless they are the active window. Use the $window->active()
to force the control's window to the top before using click()
).
Using 2 for the number of clicks will send a double-click message to the control - this can even be used to launch programs from an explorer control!
disable
$control->disable()
disables or "grays-out" the control.
enable
$control->enable()
enables a "grayed-out" control.
focus
$control->focus()
sets input focus to a given control on a window.
handle
$handle = $control->handle()
retrieves the internal handle of the control.
x
$x = $control->x()
retrieves the X coordinate of the control relative to it's window.
y
$y = $control->y()
retrieves the Y coordinate of the control relative to it's window.
width
$width = $control->width()
retrieves the width of the control.
height
$height = $control->height()
retrieves the height of the control.
text
$text = $control->text()
retrieves text from the control.
set_text
$control->set_text($text)
sets text of the control.
hide
$text = $control->hide()
hides the control.
show
$control->show()
shows a control that was hidden.
move
$control->move($x, $y)
$control->move($x, $y, $width)
$control->move($x, $y, $width, $height)
moves a control within a window.
send
$control->send($string)
$control->send($string, $flag)
sends a string of characters to the control. If $flag
is true send a raw $string
otherwise special characters like +
or {LEFT}
mean SHIFT and left arrow.
command
$result = $control->command($command, $option)
sends a command to the control.
is_visible
$boolean = $control->is_visible()
returns true if the control is visible.
is_enabled
$boolean = $control->is_enabled()
returns true if the control is enabled.
show_dropdown
$control->show_dropdown()
drops a ComboBox.
hide_dropdown
$control->hide_dropdown()
undrops a ComboBox.
add_string
$control->add_string($string)
adds a string to the end in a ListBox or ComboBox.
del_string
$control->del_string($occurrence)
deletes a string according to occurrence in a ListBox or ComboBox.
find_string
$control->find_string($string)
returns occurrence ref of the exact string in a ListBox or ComboBox.
set_selection
$control->set_selection($occurrence)
sets selection to occurrence ref in a ListBox or ComboBox.
select_string
$control->select_string($string)
sets selection according to string in a ListBox or ComboBox.
is_checked
$boolean = $control->is_checked()
returns true if a Button is checked.
check
$control->check()
checks a radio or check Button.
uncheck
$control->uncheck()
unchecks a radio or check Button.
line_number
$current_line_number = $control->line_number()
returns the line # where the caret is in an Edit.
column
$current_column = $control->column()
returns the column # where the caret is in an Edit.
selection
$current_selection = $control->selection()
returns name of the currently selected item in a ListBox or ComboBox.
line_count
$line_count = $control->line_count()
returns # of lines in an Edit.
line
$text = $control->line($line_number)
returns text at line # passed of an Edit.
selected
$text = $control->selected()
returns selected text of an Edit.
paste
$control->paste($string)
pastes the 'string' at the Edit's caret position.
tab
$current_tab = $control->tab()
returns the current Tab shown of a SysTabControl32.
tab_right
$control->tab_right()
moves to the next tab to the right of a SysTabControl32.
tab_left
$control->tab_left()
moves to the next tab to the left of a SysTabControl32.
AutoItX native methods
This module also autoloads all AutoItX methods. For example:
$control->WinActivate($win_title) unless $control->WinActive($win_title);
Please see AutoItX Help file for documenation of all available methods.
SEE ALSO
- Win32::AutoItX::Control::ListView
- Win32::AutoItX::Control::TreeView
- Win32::AutoItX::Window
- Win32::AutoItX
- AutoItX Help
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.