python - stealth window

Gabriel Genellina gagsl-py2 at
Sat Nov 10 04:21:10 CET 2007

En Thu, 08 Nov 2007 03:23:27 -0300, Adam <adamfromhungary at>  

> I want create Windows console window in stealth with Python script. I  
> tried
> search on internet but I do not find anything. I want something like this
> just it is in C++:
>     HWND stealth; /*creating stealth (window is not visible)*/
>     AllocConsole();
>    stealth=FindWindowA("ConsoleWindowClass",NULL);
>     ShowWindow(stealth,0);
> So I start my script and that is will be run in the background and I can
> trick with "hotkeys" in WINAMP. I do not worry for a new one window. :-)  
> I
> hope you understand me because my english is not perfect.

Using the pywin32 packages from Mark Hammond, this is a direct translation  
of the above:

import win32console, win32gui

stealth = win32gui.FindWindow("ConsoleWindowClass", None)
win32gui.ShowWindow(stealth, 0)
import time
win32gui.ShowWindow(stealth, 1)

You must either run it using pythonw.exe, or remove the AllocConsole call

Gabriel Genellina

More information about the Python-list mailing list