26 August 2015, 02:36 | #1 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Closing current Shell window programmatically?
Hi all!
I wonder if someone would know and could point me to a piece of C code that it a CLI program that closes the Shell window in which it runs programmatically? I tried something like: Code:
struct Window *win = get_CON_window() CloseWindow(win); Thanks! |
26 August 2015, 03:56 | #2 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
Have you tried printing an EOF to the console? On the keyboard it is represented by control-backslash.
|
26 August 2015, 11:34 | #3 |
Registered User
Join Date: Jul 2008
Location: Poland
Posts: 662
|
try Execute("endcli");
|
26 August 2015, 13:29 | #4 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
You need to detach your program from the shell that spawned it before it can close, otherwise the task expects the shell to be there for certain resources (i/o streams, OS messages and signals, current directory etc.), and pulling it out from beneath your program causes bad things to happen as you've found. I don't have any example code I'm afraid, but from memory, you need to spawn a new process with CreateProcess() or something similar (this will be your actual program), and then end your current task (which basically acts as a small launcher), thus freeing up the shell to be closed.
A much simpler option is to just use a little script to launch your program, something like: Code:
Run MyProgram >NIL: <NIL: EndCLI |
06 September 2015, 05:22 | #5 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Hi all!
Thanks for your suggestions: system("EndCLI"); closes the Shell window while printf("%c", 0x04); does not do anything, maybe I am not using the correct control character? Anyhow, I realised that closing the Shell could be very annoying so, at the end, I don't think that I should use it Thanks! |
06 September 2015, 06:24 | #6 |
Code Kitten
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
|
Closing the CLI should be the responsibility of the user or program which opened it, there is nothing more annoying than a command line program which kills your CLI or script when there are many more commands left to execute afterward.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Clear background color for Shell window- Shell-StartUp | fc.studio | support.Apps | 13 | 25 March 2022 18:52 |
UnArchiving LHA Files Programmatically: Confused about XPK, XAD, XFD | tygre | Coders. C/C++ | 18 | 17 June 2015 00:26 |
Snapshot Amiga Shell window? | TenLeftFingers | support.Apps | 3 | 15 June 2015 16:38 |
FS-UAE Launcher window resizing & closing | Emu | support.FS-UAE | 2 | 14 April 2015 10:24 |
Closing a window with shared Messageport? | AGS | Coders. System | 0 | 18 March 2015 15:05 |
|
|