use Win32::OLE; use IO::String; use Win32::Console; my $objDatabase; # use existing instance if Act is already running eval {$objDatabase = Win32::OLE->GetActiveObject('ACTOLE.DATABASE')}; die "ACT not installed" if $@; unless (defined $objDatabase) { $objDatabase = Win32::OLE->new('ACTOLE.DATABASE', sub {$_[0]->Close;}) or die "Can't start ACT"; } # duplicate STDOUT and STDIN because of a bug in ACT # this only works for STDOUT, not STDIN open(TEMPOUT, ">&STDOUT") || die("Cannot duplicate STDOUT: $!"); close STDOUT; # this one doesn't work # my $fake_stdin = "b\na\nd\nthing\n"; # tie *STDIN, 'IO::String', \$fake_stdin; # this one doesn't work, either my $STDIN = Win32::Console->new(STD_INPUT_HANDLE); $STDIN->WriteInput(1, TRUE, 3, 1, 1, 0, 0); # this line is the culprit # it waits for three keypresses $objDatabase->Open('C:\chris\contacts.DBF'); # restore STDIN open(STDOUT, ">&TEMPOUT") || die("Cannot restore STDOUT: $!"); close TEMPOUT; # after this, it works fine