pijush has asked for the wisdom of the Perl Monks concerning the following question:

Hi!

I am trying to install a software in Windows. The s/w has only GUI mode installation. I have found that Win32::Setupsup module can be used to automate the installation. But when I was trying to use this module, I faced a problem to send data in a text field and then press the "next" button. I have installed the module in Perl v5.6.1 on w2k. Here is my code

use strict; use Win32::Setupsup qw(WaitForAnyWindow GetWindowProperties SendKeys S +etFocus); my ($window); system (1, "setup.exe"); if (WaitForAnyWindow("windows name", \$window, 6000, 500)) { SetFocus ($window); sleep (2); SendKeys ($windows,'textvalue',1); sleep (1); SendKeys ($windows,'\\TAB\\',1); sleep (1); SendKeys ($windows,'\\RET\\',1); sleep (2); }
But the keystroke is not going to the text field which is desirable to me. Any pointer how to send keystroke to the text field? Any help really appreciated.

Thanks in advance.
-Pijush

Edit by tye, preserve formatting

Replies are listed 'Best First'.
Re: Help needed for using Win32::Setupsup module
by Albannach (Monsignor) on Nov 21, 2003 at 17:09 UTC
    Evidently your SETUP.EXE does not give focus to the edit box you want when it starts, so I think all you need to do is TAB your way to the desired edit box before sending your text.

    I have had to do this for a Win32 GUI app which didn't include all the edit boxes in the TAB sequence, and in that case I was able to use Win32::GuiTest to move the mouse pointer into the edit box, sent a mouse left click and then send the text - horrible in concept but worked perfectly in practice. You need to watch for screen resolution differences and calculate the mouse coordinates on the fly, but it can be done if the window always appears at the same position.

    --
    I'd like to be able to assign to an luser

      I have checked the window which appeared after running "SETUP.EXE" and the cursor is focused on desired TEXTBOX. Actually it is a password field and when you type then it appears in "*****". But when I am sending keystorke using SendKey method it is not going in the TEXTFIELD. I have also examined when I manually type from keyboard at that point (i.e. when the window appears after running "SETUP.EXE") and it is going in the text field. Any pointers? TIA -Pijush
        Hi Monks, Thanks for reply. I have cracked the problem. Albannach, you were quite right. I have written code for sending "TAB" before sending text field value and positioning the cursor at desired test box and then send the text value and it is working fine. But I am not sure why it is not sending text value at the first chance although the cursor was in the appropriate text box. Thanks again. TIA -Pijush