http://www.perlmonks.org?node_id=1027439


in reply to Re: How to handle a browser window that opens up during the execution of some external program commands
in thread How to handle a browser window that opens up during the execution of some external program commands

Hi, I'm trying to use Win32-GuiTest for this problem. Below is my observation while using this module. please let me know your suggestions on this-

1. My powershell initiated browser window doesn't has any title. So, I'm using FindWindowLike with class regex. It works somehow okay but in some scenarios, this class regex matches more windows. Is there any way to get only one window handler?

2. Once I get the window handler, is there any function to select username, password text boxes and send texts into these text boxes.

below is the sample code i'm using to identify

use Win32::GuiTest qw( :ALL ); #use strict; my @whnds = FindWindowLike( undef, "^\s*\$" , "Internet Explorer_S +erver" ); if( !@whnds ){ die "Cannot find window with title/caption Symantec Endpoint P +rotection Manager\n"; }else{ print "window handle found: [@whnds]\n"; } $text = "hi"; foreach (@whnds) { set_front_win($_); $result= WMSetText( $_, $text ); SendKeys("{TAB}"); # sleep(1); SendKeys("admin"); # sleep(1); SendKeys("{TAB}"); # sleep(1); SendKeys("crt{@}123"); # sleep(1); SendKeys("{TAB}"); # sleep(1); SendKeys("{TAB}"); # sleep(1); SendKeys("{ENTER}"); sleep(1); #PushChildButton( undef, "Authorize" ); SendKeys("{ENTER}"); }

  • Comment on Re^2: How to handle a browser window that opens up during the execution of some external program commands
  • Download Code

Replies are listed 'Best First'.
Re^3: How to handle a browser window that opens up during the execution of some external program commands
by marto (Cardinal) on Apr 08, 2013 at 08:34 UTC

    To answer both questions see spy.pl from Win32::GuiTest::Examples. Use this tool (or something similar) to determin the window/object ID. See the other examples for using this ID to interact with them.