[Tutor] Opening a cmd.exe

Tim Golden mail at timgolden.me.uk
Sun Mar 22 15:51:20 CET 2009


Tim Golden wrote:
> Alan Gauld wrote:
>> "Sigga Sig" <sigridurs07 at ru.is> wrote
>>
>>> I am writing a code that is supoesed to act as routers and i need to 
>>> open a
>>> different cmd window for each one of them with it's name and so on. I 
>>> do not
>>> know how to implement in mi Python cod a sentece that opens such a cmd.
>>>
>>> I know how to open a cmd.exe bud not with specific attributes that are
>>> needed.
>>
>> Neither do I. You can use shortcuts and set the name of the shortcut
>> and that will show up on the window title.
>>
>> There are probably ways to do it using the Win32 API too, but you would
>> need to get the Window Handle using FindWindow(). And I'm still not sure
>> which API call would set the title. I'd probably just create a set of
>> shortfcuts on a folder and execute those.
> 
> You can do it with the win32console functions from pywin32:
> 
>  win32console.SetConsoleTitle (u"blahblah")

Ah, sorry, missed the point that you're not actually running
Python code in these windows. Yes, as Alan says, you'd have
to use FindWindow to identify your windows by their existing
titles and then use SetWindowText (or whatever) to set the
title. You probably are better off using shortcuts...

TJG


More information about the Tutor mailing list