C:\Perl\site\lib\Win32>diff -c
guitest.pm guitest_old.pm *** guitest.pm Sun Jan 16 17:23:36 2005 --- guitest_old.pm Thu Dec 23 12:49:44 2004 *************** *** 385,394 **** (!$classre || $sClassname =~ /$classre/)) { DbgShow("Matched $1\n") if $1; ! if (not defined $ID) { # If find a match add handle to array: ! push @found, $hwnd; ! } elsif (defined $sID) { if ($sID == $ID) { # If find a match add handle to array: push @found, $hwnd; --- 385,394 ---- (!$classre || $sClassname =~ /$classre/)) { DbgShow("Matched $1\n") if $1; ! if (!$ID) { # If find a match add handle to array: ! push @found, $hwnd; ! } elsif ($sID) { if ($sID == $ID) { # If find a match add handle to array: push @found, $hwnd; |
In order to avoid confuses, I will use the term Win32 in order to refer to WinNT/2K/XP operating system.
Address control in
Internet Explorer |
Address control in
windows' hierarchy |
1 use Win32::GuiTest qw( FindWindowLike SendKeys
SetForegroundWindow ); 2 use strict; 3 4 # 5 # Find handle of the main window 6 # 7 print "Looking for main window's handle\n"; 8 my @hwnds = FindWindowLike( undef, "^about:blank" ); 9 if( !@hwnds ){ 10 die "Cannot find window with title/caption about:blank\n"; 11 }else{ 12 printf( "Window handle of IE application is %x\n", $hwnds[ 0 ] ); 13 } 14 15 # 16 # Find handle of the "Address" edit box 17 # 18 print "Looking for Address box window handle\n"; 19 @hwnds = FindWindowLike( $hwnds[ 0 ], undef, "Edit", 0xA205 ); 20 if( !@hwnds ){ 21 die "Cannot find Address edit box\n"; 22 }else{ 23 print "FindWindowLike returned " . scalar( @hwnds ). " handles\n"; 24 printf( "Window handle of Address edit box is %x\n", $hwnds[ 0 ] ); 25 } 26 27 SetForegroundWindow( $hwnds[ 0 ] ); 28 SendKeys( "www.piotrkaluski.com~" ); |
test1.pl |
Control
ids in IE |
1 use Win32::GuiTest qw( FindWindowLike ); 2 use strict; 3 4 # 5 # Find a handle of the main window 6 # 7 print "Looking for main window's handle\n"; 8 my @hwnds = FindWindowLike( undef, "^about:blank" ); 9 if( !@hwnds ){ 10 die "Cannot find window with title/caption about:blank\n"; 11 }else{ 12 printf( "Window handle of IE application is %x\n", $hwnds[ 0 ] ); 13 } 14 15 # 16 # Find handle of the Menu Bar 17 # 18 @hwnds = FindWindowLike( $hwnds[ 0 ], undef, "ToolbarWindow32", 0 ); 19 if( !@hwnds ){ 20 die "Cannot find toolbars\n"; 21 }else{ 22 printf( "Found " . scalar( @hwnds ) . " handles for ToolbarWindow32 " . 23 "with control id = 0\n" ); 24 } 25 |
test2.pl |
@hwnds = FindWindowLike( $hwnds[ 0 ], undef, "ToolbarWindow32", 0, 4 ); |
1 use Win32::GuiTest qw( FindWindowLike ); 2 use strict; 3 4 # 5 # Find a handle of the main window 6 # 7 print "Looking for main window's handle\n"; 8 my @hwnds = FindWindowLike( undef, "^about:blank" ); 9 if( !@hwnds ){ 10 die "Cannot find window with title/caption about:blank\n"; 11 }else{ 12 printf( "Window handle of IE application is %x\n", $hwnds[ 0 ] ); 13 } 14 15 # 16 # Find handle of the Menu Bar 17 # 18 @hwnds = FindWindowLike( $hwnds[ 0 ], undef, "ToolbarWindow32", 0, 4 ); 19 if( !@hwnds ){ 20 die "Cannot find toolbars\n"; 21 }else{ 22 printf( "Found " . scalar( @hwnds ) . " handles for ToolbarWindow32 " . 23 "with control id = 0\n" ); 24 printf( "Menu bar has a window handle %x\n", $hwnds[ 1 ] ); 25 } 26 |
test3.pl |
1 use Win32::LGT::Window; 2 use strict; 3 4 my $win = Win32::LGT::Window->AttachMainWindow( 5 'caption' => "^about:blank - Microsoft", 6 'win_def_fname' => "ie.xml" ); 7 8 my $handle = $win->Ctrl( "MenuBar" )->{ 'handle' }; 9 printf( "Handle of Menu Bar is %x", $handle ); 10 print "\n"; |
test4.pl |
1 <opt id="0x2002d5" caption="about:blank -
Microsoft Internet Explorer" class="IEFrame"> 2 <CONTROL name="UpperPanel" caption="" class="WorkerW" id="0xa005"> 3 <CONTROL name="ReBar" caption="" class="ReBarWindow32" id="0xa005"> 4 <CONTROL id="0x0" caption="Links" class="ToolbarWindow32" idx="0"> 5 </CONTROL> 6 <CONTROL name="MiddlePanel" caption="" class="ComboBoxEx32" id="0xa205"> 7 <CONTROL name="Ctrl1" caption="" class="ToolbarWindow32" id="0x0"> 8 </CONTROL> 9 <CONTROL name="Address" caption="" class="ComboBox" id="0xa205"> 10 <CONTROL name="Ctrl1" caption="" class="Edit" id="0xa205"> 11 </CONTROL> 12 </CONTROL> 13 </CONTROL> 14 <CONTROL name="Ctrl2" caption="" class="ToolbarWindow32" id="0xa000"> 15 </CONTROL> 16 <CONTROL name="Ctrl3" caption="" class="WorkerW" id="0x0"> 17 </CONTROL> 18 <CONTROL name="MenuBar" caption="" class="ToolbarWindow32" id="0x0" idx="1"> 19 </CONTROL> 20 </CONTROL> 21 </CONTROL> 22 <CONTROL name="Ctrl2" caption="" class="WorkerW" id="0x270f"> 23 </CONTROL> 24 <CONTROL name="Ctrl3" caption="" class="msctls_statusbar32" id="0xa001"> 25 <CONTROL name="Ctrl1" caption="" class="msctls_progress32" id="0x1"> 26 </CONTROL> 27 </CONTROL> 28 <CONTROL name="Ctrl4" caption="" class="Shell DocObject View" id="0x0"> 29 <CONTROL name="Ctrl1" caption="" class="Internet Explorer_Server" id="0x0"> 30 </CONTROL> 31 </CONTROL> 32 </opt> |
ie.xml |
1 use Win32::LGT::Window; 2 use strict; 3 4 my $win = Win32::LGT::Window->AttachMainWindow( 5 'caption' => "^about:blank - Microsoft", 6 'win_def_fname' => "ie.xml" ); 7 8 $win->Ctrl( "UpperPanel.ReBar.MiddlePanel.Address" )-> 9 SetValue( "www.piotrkaluski.com~" ); 10 my $handle = $win->Ctrl( "UpperPanel.ReBar.MenuBar" )->{ 'handle' }; 11 printf( "Handle of Menu Bar is %x", $handle ); 12 print "\n"; |
test5.pl |
1 <opt id="0x2002d5" caption="about:blank -
Microsoft Internet Explorer" class="IEFrame"> 2 <ALIAS name="Address">UpperPanel.ReBar.MiddlePanel.Address</ALIAS> 3 <ALIAS name="MenuBar">UpperPanel.ReBar.MenuBar</ALIAS> 4 <CONTROL name="UpperPanel" caption="" class="WorkerW" id="0xa005"> 5 <CONTROL name="ReBar" caption="" class="ReBarWindow32" id="0xa005"> 6 <CONTROL id="0x0" caption="Links" class="ToolbarWindow32" idx="0"> 7 </CONTROL> 8 <CONTROL name="MiddlePanel" caption="" class="ComboBoxEx32" id="0xa205"> 9 <CONTROL name="Ctrl1" caption="" class="ToolbarWindow32" id="0x0"> 10 </CONTROL> 11 <CONTROL name="Address" caption="" class="ComboBox" id="0xa205"> 12 <CONTROL name="Ctrl1" caption="" class="Edit" id="0xa205"> 13 </CONTROL> 14 </CONTROL> 15 </CONTROL> 16 <CONTROL name="Ctrl2" caption="" class="ToolbarWindow32" id="0xa000"> 17 </CONTROL> 18 <CONTROL name="Ctrl3" caption="" class="WorkerW" id="0x0"> 19 </CONTROL> 20 <CONTROL name="MenuBar" caption="" class="ToolbarWindow32" id="0x0" idx="1"> 21 </CONTROL> 22 </CONTROL> 23 </CONTROL> 24 <CONTROL name="Ctrl2" caption="" class="WorkerW" id="0x270f"> 25 </CONTROL> 26 <CONTROL name="Ctrl3" caption="" class="msctls_statusbar32" id="0xa001"> 27 <CONTROL name="Ctrl1" caption="" class="msctls_progress32" id="0x1"> 28 </CONTROL> 29 </CONTROL> 30 <CONTROL name="Ctrl4" caption="" class="Shell DocObject View" id="0x0"> 31 <CONTROL name="Ctrl1" caption="" class="Internet Explorer_Server" id="0x0"> 32 </CONTROL> 33 </CONTROL> 34 </opt> |
ie_aliased.xml |
1 use Win32::LGT::Window; 2 use strict; 3 4 my $win = Win32::LGT::Window->AttachMainWindow( 5 'caption' => "^about:blank - Microsoft", 6 'win_def_fname' => "ie_aliased.xml" ); 7 8 $win->Ctrl( "Address" )->SetValue( "www.piotrkaluski.com~" ); 9 my $handle = $win->Ctrl( "MenuBar" )->{ 'handle' }; 10 printf( "Handle of Menu Bar is %x", $handle ); |
test6.pl |
1 <opt id="0x2002d5" caption="about:blank -
Microsoft Internet Explorer" class="IEFrame"> 2 <ALIAS name="Address">UpperPanel.ReBar.MiddlePanel.Address</ALIAS> 3 <ALIAS name="MenuBar">UpperPanel.ReBar.MenuBar</ALIAS> 4 <CONTROL name="UpperPanel" caption="" class="WorkerW" id="0xa005"> 5 <CONTROL name="ReBar" caption="" class="ReBarWindow32" id="0xa005"> 6 <CONTROL name="MiddlePanel" caption="" class="ComboBoxEx32" id="0xa205"> 7 <CONTROL name="Address" caption="" class="ComboBox" id="0xa205"> 8 <CONTROL name="Ctrl1" caption="" class="Edit" id="0xa205"> 9 </CONTROL> 10 </CONTROL> 11 </CONTROL> 12 <CONTROL name="MenuBar" caption="" class="ToolbarWindow32" id="0x0" idx="1"> 13 </CONTROL> 14 </CONTROL> 15 </CONTROL> 16 </opt> |