Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
console only OR screen only
#2
@mdijkens it's possible to improve the situation but unfortunately Windows makes it impossible to get exactly what you want.

The way to improve your application is to use `$ScreenHide`, this will stop the program from creating the graphics window at start-up (it will be delayed until the first `_ScreenShow`) and prevent the window from popping-up when run from a console. If you run that application with no parameters though (Ex. double-chick) it will still create a console window briefly like you're seeing. That issue is caused by the `$Console` line, but you can't remove it since you want your application to work correctly from the console.

The underlying issue is that Windows classifies applications as either a console application or a GUI application. When you use `$Console` you're declaring that your application is a console application, which means:

1. Your application always gets a console, if not started from an existing console one is created.
2. When started from an existing console, that console will wait for your program to exit before continuing on (and output from your program will go to that console).

That last one is the big issue and why you don't want your application to be GUI application. When you start a GUI application from an existing console, the console immediately returns to the prompt and doesn't wait for the GUI program to end, so you can't realistically output anything. You can see this if you open `cmd` or `powershell` and run `notepad`, that's a GUI application so the console doesn't wait for `notepad `to exit before showing the prompt again.

What you might consider is skipping the graphics window entirely and make it a console-only application. You should be able to use `Input` from the console to read your parameters, that might be good enough for your use-case.
Reply


Messages In This Thread
console only OR screen only - by mdijkens - 09-04-2024, 07:47 PM
RE: console only OR screen only - by DSMan195276 - 09-04-2024, 08:05 PM
RE: console only OR screen only - by mdijkens - 09-04-2024, 09:34 PM



Users browsing this thread: 2 Guest(s)