C++ Application that doesn't steal focus and just runs

I'd like to make a simple, small application which, when started doesn't steal focus, shows in the process list and runs until I stop it.

Unfortunately I have no experience with this type of scripting so I'd like some help, Thanks!
closed account (Dy7SLyTq)
theres porbably something in the windows api
What platform are you on?
Last edited on
Hi. I am using Visual Studio 2013 Preview.
closed account (Dy7SLyTq)
so windows thumper
The only way I know to do what you're asking is platform dependent, so this will only work on Windows.
You can hide the console window with the Windows API function ShowWindow: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx
You can create a function to hide your console window something like the following:
#include <windows.h>
void HideConsole()
    HWND hConsole;
    hConsole = FindWindowA("ConsoleWindowClass", NULL);
    ShowWindow(hConsole, SW_HIDE);


While building the above solution I get the following error:

"Error 1 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? c:\users\urban\documents\visual studio 2013\projects\win32project3\win32project3\win32project3.cpp 8 1 Win32Project3"

Thanks for the help!
If you're talking Windows specific, you could just make it a Windows app (rather than a Windows console app) and not create a GUI.


PS @Thumper

If you want to get the HWND of your console app's (console) window, you can just use

GetConsoleWindow function
(for Windows 2000 and after.)


can you be so good to provide the actual code please, I'm having a lot of problems with this and can't get it working.

Thank you!

Edit: Managed it.
Last edited on
Topic archived. No new replies allowed.