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.


In reply to Re^2: Writting and reading from windows applications by ldln
in thread Writting and reading from windows applications by mineiro

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.