Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Win32 and Perl

2 views
Skip to first unread message

Ernesto Guisado

unread,
Aug 28, 1998, 3:00:00 AM8/28/98
to

stevel wrote in message ...

>applications such as Excel through the OLE package on Perl. What about
>pulling up things such as dialog boxes, file browsers, etc for interactive
>use in scripts? Is it possible to do this? If so, could someone point me
>towards an online guide as to how to do this (with examples?)


In Visual Basic and brethren you can use the SendKeys function. Some time
ago Al Williams published a Delphi version in Dr. Dobb's
(http://www.ddj.com/ddj/1997/careers1/wil2.htm). I ported it to C and
packaged it using h2xs...

The tentative name for this module is Win32::Test (after the name of the
most probable use for this kind of function):

use Win32::Test;
use Win32::Process;
use Win32::WinError;
sub ErrorReport{ print Win32::GetLastError(); }

# Open Excel
Win32::Process::Create($ProcessObj,
"C:\\Program Files\\Microsoft Office\\Office\\EXCEL.EXE",
"",
0,
NORMAL_PRIORITY_CLASS,
".") or die ErrorReport();

# Wait during startup...
$ProcessObj->Wait(10000);

# ALT-f, n should create a new file in the English version of Excel
Win32::Test::SendKeys("%fn~");

#Wait some more
$ProcessObj->Wait(5000);

# Insert some stuff into the spreadsheet
Win32::Test::SendKeys("a{TAB}b{TAB}~");

# Wait until somebody closes Excel
$ProcessObj->Wait(INFINITE);

If you want to know the exact format of the string you pass to Sendkeys, a)
see the VB docs b) see the Al Williams article noted above.

If anybody is interested I'll post the module.

Regards,
Ernesto.


0 new messages