I tested my 'ConsolePrint' script, and noticed that if you close the console window, the AHK process is also closed. Is there a way to prevent this?
A workaround is to disable the Close button:
Code: Select all
;SC_CLOSE := 0xF060 ;MF_BYCOMMAND := 0x0
if (hWnd := DllCall("kernel32\GetConsoleWindow", "Ptr"))
&& (hMenu := DllCall("user32\GetSystemMenu", "Ptr",hWnd, "Int",0, "Ptr"))
DllCall("user32\DeleteMenu", "Ptr",hMenu, "UInt",0xF060, "UInt",0x0)
This link suggests it may not be possible to prevent this:
c++ - How can I prevent my program from closing when a open console window is closed? - Stack Overflow
https://stackoverflow.com/questions/20232685/how-can-i-prevent-my-program-from-closing-when-a-open-console-window-is-closed