NAME
Win32::CtrlGUI::Window - an OO interface for controlling Win32 GUI windows
SYNOPSIS
use Win32::CtrlGUI
my $window = Win32::CtrlGUI::wait_for_window(qr/Notepad/);
$window->send_keys("!fx");
DESCRIPTION
Win32::CtrlGUI::Window
objects represent GUI windows, and are used to interact with those windows.
METHODS
_new
This method is titled _new
because it would rarely get called by user-level code. It takes a passed window handle and returns a Win32::CtrlGUI::Window
object.
text
This method returns the window's text. Rarely used because the stringification operator for Win32::CtrlGUI::Window
is overloaded to call it. Thus, instead of writing print $window->text,"\n";
, one can simply write print $window,"\n";
If you want to print out the handle number, write print $window->handle,"\n"
or print int($window),"\n"
.
handle
This method returns the window's handle. Rarely used because the numification operator for Win32::CtrlGUI::Window
is overloaded to call it.
send_keys
I found the SendKeys
syntax used by Win32::Setupsup
to be rather unwieldy. I missed the syntax used in WinBatch, so I implemented a conversion routine. At the same time, I extended the syntax a little. I think you'll like the result.
The meta-characters are:
- !
-
Holds the Alt key down for the next character
- ^
-
Holds the Ctrl key down for the next character
- +
-
Holds the Shift key down for the next character
- { and }
-
Used to send special characters, sequences, or for sleeping
The !
, ^
, and +
characters can be combined. For instance, to send a Ctrl-Shift-F7, one uses the sequence ^+{F7}
.
The special characters sendable using the curly braces are:
Alt {ALT}
Backspace {BACKSPACE} or {BS} or {BACK}
Clear {CLEAR}
Delete {DELETE} or {DEL}
Down Arrow {DOWN} or {DN}
End {END}
Enter {ENTER} or {RET}
Escape {ESCAPE} or {ESC}
F1->F12 {F1}->{F12}
Help {HELP}
Home {HOME} or {BEG}
Insert {INSERT} or {INS}
Left Arrow {LEFT}
NumKey 0->9 {NUM0}->{NUM9}
NumKey /*-+ {NUM/} or {NUM*} or {NUM-} or {NUM+}
Page Down {PGDN}
Page Up {PGUP}
Right Arrow {RIGHT}
Space {SPACE} or {SP}
Tab {TAB}
Up Arrow {UP}
! {!}
^ {^}
+ {+}
} {}}
{ {{}
If the character name is followed by a space and an integer, the key will be repeated that many times. For instance, to send 15 down arrows keystrokes, use {DOWN 15}
. To send 5 asterisks, use {* 5}
. This doesn't work for sending multiple number keys (unless you use NUM0 or some such).
Finally, if the contents of the {} block are a number - either integer or floating point, a pause will be inserted at the point. For instance, $window->send_keys("!n{2.5}C:\\Foo.txt{1}{ENTER}")
is equivalent to:
$window->send_keys("!n");
Win32::Sleep(2500);
$window->send_keys("C:\\Foo.txt");
Win32::Sleep(1000);
$window->send_keys("{ENTER}");
Hope you like the work.
enum_child_windows
Returns a list of the window's child windows. They are, of course, Win32::CtrlGUI::Window
objects.
has_child
Checks to see whether the window has a child window matching the passed criteria. Same criteria options as found in Win32::CtrlGUI::wait_for_window
. Returns 0 or 1.
set_focus
Calls Win32::Setupsup::SetFocus
on the window. See the Win32::Setupsup::SetFocus
documentation for caveats concerning this method.
get_properties
Calls Win32::Setupsup::GetWindowProperties
on the window. Passes the list of requested properties and returns the list of returned values in the same order.
get_properties
Calls Win32::Setupsup::SetWindowProperties
on the window.