in reply to Writting and reading from windows applications

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?

  • Comment on Re: Writting and reading from windows applications

Replies are listed 'Best First'.
Re^2: Writting and reading from windows applications
by ldln (Pilgrim) on Sep 21, 2004 at 20:08 UTC
    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.