RE: Multiple entry points (MS Windows)
"Watson, Keith R" <[email protected]> Fri, 24 Apr 2020 15:15:15 +0000
| Newsgroups | gmane.comp.lang.perl.par |
|---|---|
| Message-ID | <BN6PR07MB34927BD7134CB11BF1AB92A09BD00@BN6PR07MB3492.namprd07.prod.outlook.com> |
On Windows there are multiple ways to run a program and suppress a Window.
I usually run the program from a shortcut that is set to "Minimize" by default.
That way it just shows up as an icon on the task bar instead of a console Window.
This site walks through multiple ways to run any Windows app with no Window.
https://www.winhelponline.com/blog/run-bat-files-invisibly-without-displaying-command-prompt/
If you want to do it using the Perl program itself then you can use the Win32::GUI package.
In your code test for the operating system and on Windows have a command line option to hide the Window.
This program will hide its own console on Windows. The console will flash briefly on the screen and then hide. I usually start an app like this using a shortcut that starts minimized. That way there is an icon that briefly shows up on the task bar and disappears while the program continues to run.
use warnings;
use strict;
use Win32::GUI;
my $console = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($console);
system ('timeout 10');
keith
--
Keith R. Watson GCIH Georgia Institute of Technology
Information Security Engineer Lead College of Computing
[email protected] 801 Atlantic Drive NW
(404) 385-7401 Atlanta, GA 30332-0280
> -----Original Message-----
> From: Roderich Schupp <[email protected]>
> Sent: Friday, April 24, 2020 09:18
> To: Johan Vromans <[email protected]>
> Cc: [email protected]
> Subject: Re: Multiple entry points (MS Windows)
>
> On Fri, Apr 24, 2020 at 2:36 PM Johan Vromans <[email protected]
> <mailto:[email protected]> > wrote:
>
>
> But on Windows it matters whether the program is built with --gui or
> not.
> If I build with --gui invoking the command line version will make
> all
> terminal output disappear. If built without --gui the GUI invokation
> will
> show a nasty terminal window...
>
> Is there an elegant solution?
>
>
>
> AFAICS no. --gui sets a bit in the generated Windows executable, so it's
> not modifiable at runtime.
>
> Cheers, Roderich