I haven't done this in a long while and I know there are new modules to make this easier. I searched at search.cpan.org using "win32 ui" and saw these modules mentioned:
Win32::GuiTest - looks interesting, although ActiveState only has an old old version (1.3 vs. 1.5)
Win32::CtrlGUI uses Win32::Setupsup
and also looks interesting
Maybe you could use "Super Search" on some of these names to find other postings on PM? | [reply] |
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. | [reply] [d/l] |
Your question has very little chance of being answered helpfully because the question itself is not very clear.
Is your application a native Windows application (probably so, since you say it is a Delphi app)? If so, what does it have to do with Perl?
If you want to use Perl to fill in input fields in a Delphi app and read the result of that action from yet another field, you have to provide more information on how your Delphi app is going to interact with Perl. Does your app write out the info to a file on the disk that you could read? Is there some other interprocess communication possible? | [reply] |
Thank you very much guys!
I make some tests using Win32::GuiTest and working fine! | [reply] |