Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an enter to a system call

Status
Not open for further replies.

countercycle

Programmer
Joined
Aug 21, 2003
Messages
2
Location
US
I'm trying to start a system command, then simulate an enter key being pressed (activestate 5.6.1). I've come up with this code, but it doesn't quite work.

open(MORE,"|more readme");
print MORE "\n";
close(MORE);

Can anybody help?
 
Your best bet is to use the module Win32::GuiTest. It has a function called SendKeys that lets you send keystrokes to the acitve windows as if typed at the keyboard.

example code:

use Win32::GuiTest;

Win32::GuiTest(SendKeys {ENTER});

You can read the docs at:

 
If you dont want to use an extra module, you can send an enter key this way.

print chr 13

which prints the enter key.

ex:

my $enter = chr 13;
open(MORE,"|more readme");
print $enter;
close(MORE);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top