Author Topic: Creating command line option to hide running of application  (Read 3925 times)

0 Members and 1 Guest are viewing this topic.

Offline IronMan

  • Newbie
  • Posts: 38
    • View Profile
Creating command line option to hide running of application
« on: March 30, 2020, 01:04:15 pm »
I have a small QB64 application, and I am needing to be able to run it in a hidden state. I would like to be able to pass a command line option to it like " application.exe -h", the -h meaning HIDE. I'm needing the application to run normally but with no screen writes.
I have done this using the SHELL _HIDE to hide windows from viewing things being ran with shell, but I need it to hide the entire application. The application does have text output to the screen when ran, but need the ability to run it with or without screen output.

Any help or information is greatly appreciated.

Thank you.
-Kent


Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Creating command line option to hide running of application
« Reply #1 on: March 30, 2020, 01:07:50 pm »
Try _SCREENHIDE

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Creating command line option to hide running of application
« Reply #2 on: March 30, 2020, 02:09:39 pm »
With _SCREENHIDE the QB64 exe icon will also be hidden from the taskbar. You will need to us _SCREENSHOW somewhere in the program to get it, and the program window back; otherwise, you might have to use Task Manager, if running in Windows, to terminate the application if your app runs in a loop waiting for some kind of response. There are also metacommands, $SCREENHIDE and $SCREENSHOW. https://www.qb64.org/wiki/$SCREENSHOW

I would recommend reading up on these statements by checking out the link, and the associated links to the other _SCREEN... statements, above before messing with this command.

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline IronMan

  • Newbie
  • Posts: 38
    • View Profile
Re: Creating command line option to hide running of application
« Reply #3 on: March 30, 2020, 02:50:40 pm »
Pete

Thanks for the info.

So how would you pass a command line option to the program to enable $SCREENHIDE?

Looking to do something like  "application.exe -h" to make it run in hidden mode, otherwise it would run normal if no command line option is used.

Thanks.
-Kent

Offline IronMan

  • Newbie
  • Posts: 38
    • View Profile
Re: Creating command line option to hide running of application
« Reply #4 on: March 30, 2020, 03:17:46 pm »
Got it working... That was far more easier than I was thinking..

IF COMMAND$ = "-h" THEN
_SCREENHIDE
ELSE
END IF


I have tested with and without the -h command option and it works perfect.

Thanks.
-Kent

Offline IronMan

  • Newbie
  • Posts: 38
    • View Profile
Re: Creating command line option to hide running of application
« Reply #5 on: March 30, 2020, 03:58:04 pm »
I may have spoken to soon.

Although when I use the code at the beginning of my app,

IF COMMAND$ = "-h" THEN
_SCREENHIDE
ELSE
END IF


It does stop the program from running in the foreground. However the first time you run it, it still shows the WINDOW.
After it's runs for the first time, it no longer show the window. Anyone have any ideas on this?

Thank you.
-Kent


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Creating command line option to hide running of application
« Reply #6 on: March 30, 2020, 07:16:16 pm »
$SCREENHIDE
IF COMMAND$ = "-h" THEN 'the screen is hidden by default
ELSE
_SCREENSHOW 'and we unhide it if the "-h" flag is absent
END IF
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline IronMan

  • Newbie
  • Posts: 38
    • View Profile
Re: Creating command line option to hide running of application
« Reply #7 on: March 31, 2020, 12:53:27 pm »
$SCREENHIDE
IF COMMAND$ = "-h" THEN 'the screen is hidden by default
ELSE
_SCREENSHOW 'and we unhide it if the "-h" flag is absent
END IF

Yea, that's what I'm doing and it works good. However, is there a way to not show the Window? I need a way to make it run completely hidden.

Thanks.
-Kent