I'm doing some Web-based integration work with a Win32 program called ACT!, and I've run into a snag. Using Win32::OLE, one of the object posts an (erroneous) error to the console and waits for a keypress before continuing. Since the error is erroneous, the rest of the program works fine as long as it gets past the keypresses.
From a Web back-end, though, I can't figure out how to trick the OLE process into thinking it's recieved the keypresses. I can close and re-open STOUT just fine, but STDIN doesn't want to budge.
Any ideas?
The code looks a little like this:
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
Any ideas or suggestions would be greatly appreciated.
In reply to Win32::OLE redirect STDIN? by CMonster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |