Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: How can I close a Windows program called from a my Perl script?

by BrowserUk (Patriarch)
on Jan 18, 2013 at 22:52 UTC ( [id://1014149]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How can I close a Windows program called from a my Perl script?
in thread How can I close a Windows program called from a my Perl script?

Then you might be able to use something like this which starts a copy of notepad aysnchronously (system 1, ...), then waits 10 seconds before sending it the Alt-F X key sequnce to close it:

#! perl -slw use strict; use Win32::GuiTest qw[FindWindowLike SetForegroundWindow SendKeys]; system 1, q[notepad.exe]; Win32::Sleep( 10000 ); for ( FindWindowLike( undef, 'Notepad' ) ) { SetForegroundWindow( $_); SendKeys( '%fx', 5 ); }

Note: that as coded, this will close all running copies of notepad. To be more selective, see the pod for Win32::GuiTest::FindWindowLike().


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
), then waits 10 seconds before sending it the Alt-F X key sequnce to close it: #! perl -slw use strict; use Win32::GuiTest qw

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1014149]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 08:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found