#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Win32::GuiTest qw(FindWindowLike GetWindowText GetForegroundWindow SetForegroundWindow SendKeys PushButton); use Thread; my $info; sub waitForSeconds { select (undef, undef, undef, $_[0]); } sub HandleDialog { my $max = shift; my $found = 0; my $tries = 0; while (($found < 2) && ($tries++ < $max)){ waitForSeconds(.2); my ($dialog) = FindWindowLike(0, "^perl.exe", ""); if ($dialog){ print "Found dialog!\n"; SetForegroundWindow($dialog); $found++; PushButton("Continue"); } else { print "Did not find dialog\n"; last; } } } sub checkdir { my $dir = shift; my $t = Thread->new(\&HandleDialog, 10); my @data = stat($dir); $t->join(); if (@data){ print Dumper(\@data); } else { warn "Could not stat $dir"; return; } opendir(DH, $dir) || warn "Could not open $dir"; while ((my $entry = readdir(DH))){ print "Got $entry from $dir\n"; } closedir(DH); } foreach my $arg (@ARGV){ checkdir($arg); }