$|++; use strict; use Win32; use Win32::GuiTest qw(:ALL :SW); use vars qw /%data/; #$data{apps_list} = shift @ARGV; $data{host} = Win32::NodeName(); system (cls); my @windows = FindWindowLike(0, 'Clean Spooler'); for my $win (@windows) { print "Found window $win with title '", GetWindowText($win), "'\n"; my @children = GetChildWindows($win); for my $child (@children) { my $text = GetWindowText($child); next if ($text =~ /^\xff/); # you've found the icon next if ($text =~ /^OK|Cancel|Abort|Retry|Ignore|Yes|No$/); # you've found a button print "Found child $child with text '$text'\n"; } } #### Found window 5440342 with title 'Clean Spooler' Found child 1245952 with text 'To restore the spooler to its original state, enter the name of the computer on which to restore th e spooler, and click the Clean Spooler button. All print jobs, printers, printer drivers, and spool files on the specified comput er will be deleted.' Found child 787128 with text 'Computer &Name:' Found child 5309426 with text '' Found child 787116 with text 'S&elect...' Found child 787136 with text '&Save Spooler Registry to File' Found child 1245870 with text '&File:' Found child 1835774 with text '' Found child 852698 with text '&Browse...' Found child 983782 with text '&Clean Spooler' Found child 656042 with text 'C&lose' Found child 918252 with text '' Found window 1245952 with title 'To restore the spooler to its original state, enter the name of the computer on which to restore the spooler, and click the Clean Spooler button. All print jobs, printers, printer drivers, and spool files on the specified comp uter will be deleted.' Found window 983782 with title '&Clean Spooler' #### use strict; use Win32::GuiTest qw( FindWindowLike SetForegroundWindow SendKeys PushChildButton GetChildWindows GetWindowText ); my @whnds = FindWindowLike( undef, "^Clean Spooler" ); if( !@whnds ) { die "Cannot find window with title/caption specified\n"; } else { printf( "Window handle of specified application is %x\n", $whnds[ 0 ] ); SetForegroundWindow( $whnds[ 0 ] ); SendKeys( "\\\\SN02GET18a" ); SendKeys("{ENTER}"); SendKeys("{RIGHT}"); SendKeys("{ENTER}"); SendKeys("{RIGHT}"); SendKeys("{ENTER}"); SendKeys("{ENTER}"); }