Yes, Win32::GuiTest can do this. I was interested by your post and have tried the procedure with the module and it works, though it's a bit of a fiddle to get it sat up right the first time around.. I used handler 1.5 to lookup the different widgets classnames, Control IDs, Texts, handles etc. A Must-have tool for this operation.
Here is some code for what I did. I've got this app that shows a registration nag-screen each time it starts. I wanted to fill in some dummy data and then close the nag window.
use strict;
use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWi
+ndow
SendKeys GetChildWindows GetClassName GetPar
+ent);
#Get our "mainwindow" - various search criteria can can be used.
#FindWindowLike ($window,$titleregex,$classregex,$childid,$maxleve
+l)
my @windows = FindWindowLike(0, qr/Iris License Registration/i,und
+ef,undef,);
#Go through all widgets and sort out the ones we're interested i
+n
for (@windows) {
#Mainwindow has no parents..here we start
if (! GetParent($_) ) {
#dumps all children widget handles
my @chld = GetChildWindows($_);
#Dump handles to the two text-input fields we want
#We lookup the classname for the widgets with handWler1
+.5, which is 'Edit'
my @text_field;
for (@chld) {
#Get handle to the empty text-input fields
if ( (GetClassName($_) =~ m/Edit/) && (GetWindowText($
+_) eq '') ) {
push @text_field,$_;
}
}
#Now we have handles to widgets we wanna manipulate..
#We insert text into the two input fields ("Registered To"
+ and "Licence Key")
#Get text field we wanna manipulate in the foreground. A
+ctivates windows and widget..
SetForegroundWindow($text_field[0]);
#Hm..WaitWindowLike() wouldn't not work..Not exported an
+d not defined.. ??!
#..instead we just wait a little, just in case..
select (undef,undef,undef,0.50);
#The "crux"..nice. Also we use 50 ms delay between each
+ key input.
SendKeys("Joe Doe",50);
#Go to next text-field, "serial nr field"...{TAB} key co
+uld have been used instead..
SetForegroundWindow($text_field[1]);
SendKeys("12345678acme{ENTER} ",50);
last;
}
}
The module installs without problems with ppm on perl 5.8.3 build 809. |