Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to hide/inhibit the console window when launching a Perl script on Windows?

by jdporter (Paladin)
on Mar 13, 2006 at 15:12 UTC ( [id://536265]=note: print w/replies, xml ) Need Help??


in reply to How to hide/inhibit the console window when launching a Perl script on Windows?

Use Win32::API. The following code does exactly what Win32::GUI does.
use Win32::API 0.20; # just for completeness... use constant SW_HIDE => 0; use constant SW_SHOWNORMAL => 1; # the API we need my $GetConsoleTitle = new Win32::API('kernel32', 'GetConsoleTitle', 'P +N', 'N'); my $SetConsoleTitle = new Win32::API('kernel32', 'SetConsoleTitle', 'P +', 'N'); my $FindWindow = new Win32::API('user32', 'FindWindow', 'PP', 'N'); my $ShowWindow = new Win32::API('user32', 'ShowWindow', 'NN', 'N'); # save the current console title my $old_title = " " x 1024; $GetConsoleTitle->Call( $old_title, 1024 ); # build up a new (fake) title my $title = "PERL-$$-".Win32::GetTickCount(); # sets our string as the console title $SetConsoleTitle->Call( $title ); # sleep 40 milliseconds to let Windows rename the window Win32::Sleep(40); # find the window by title $hw = $FindWindow->Call( 0, $title ); # restore the old title $SetConsoleTitle->Call( $old_title ); # hide the console! $ShowWindow->Call( $hw, SW_HIDE ); # sleep one second, then show the console again sleep(1); $ShowWindow->Call( $hw, SW_SHOWNORMAL );
  • Comment on Re: How to hide/inhibit the console window when launching a Perl script on Windows?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-25 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found