How do I un-group my GUI from other python scripts in the MSW taskbar?

When I open one GUI, my Frame name shows up with the icon I set to it in the Windows taskbar. But when I open more than one GUI, the icon changes to the default Python icon, and the name changes from the Frame title to ‘pythonw’ (pythonw.exe is the interpreter I’m calling the scripts with).

Online I found a win32/ctypes fix, but it only seems to work for >WinXP (and I’m developing for WinXP). That fix is the SetCurrentProcessExplicitAppUserModelID call.

Werner recommended I try wx.App.SetAppName(myWxApp, ‘newAppNameString’) but that had no effect.

In #winapi on Freenode IRC, someone said I could copy the pythonw.exe and rename it every time I launch a GUI… but said that some virus scanner programs might not be happy about that. I haven’t tried it to see if the corporate-wide virus protection would complain or not, but I’d prefer a more pythonic way of doing this. Even if it’s a bunch of C-looking win32-specific code (I only have to worry about this working on Windows).

Here’s my failed (at least currently) attempt at trying to change the process name. This was adapted from some Visual Basic code I found online. While it does change the process name in task manager, I don’t think I’m converting the string correctly as the process name changes to garbage or non-English characters.

(apparently some people don’t like pastebin so here http://paste.pound-python.org/show/rY6OzCpK6NmDlUYAdhl5/ )

Now I’m not sure if it is a result of the garbage characters, or that something else is fundamentally wrong with this approach, but my GUI processes didn’t seem to ungroup (when I had a break call just after SetItemText so only the first .EXE item was getting changed). I also didn’t see the taskbar group name ‘pythonw’ change to garbage with the code as-pasted (i.e. without a break after SetItemText, so it will change all pythonw.exe process names)

Can some win32 wizard see the error in my idea/implementation?

testchprocname.py (6.12 KB)

···

On Tuesday, September 16, 2014 10:30:44 AM UTC-7, Nathan McCorkle wrote:

When I open one GUI, my Frame name shows up with the icon I set to it in the Windows taskbar. But when I open more than one GUI, the icon changes to the default Python icon, and the name changes from the Frame title to ‘pythonw’ (pythonw.exe is the interpreter I’m calling the scripts with).

Online I found a win32/ctypes fix, but it only seems to work for >WinXP (and I’m developing for WinXP). That fix is the SetCurrentProcessExplicitAppUserModelID call.

Werner recommended I try wx.App.SetAppName(myWxApp, ‘newAppNameString’) but that had no effect.

In #winapi on Freenode IRC, someone said I could copy the pythonw.exe and rename it every time I launch a GUI… but said that some virus scanner programs might not be happy about that. I haven’t tried it to see if the corporate-wide virus protection would complain or not, but I’d prefer a more pythonic way of doing this. Even if it’s a bunch of C-looking win32-specific code (I only have to worry about this working on Windows).

Nathan McCorkle wrote:

Here's my failed (at least currently) attempt at trying to change the
process name. This was adapted from some Visual Basic code I found
online. While it does change the process name in task manager, I don't
think I'm converting the string correctly as the process name changes
to garbage or non-English characters.

Are you on a 64-bit operating system? The LVITEM structure you're
building assumes it will be used in a 32-bit process. (The
SharedProcMemString is being encoded as a 32-bit value.) If you're on a
64-bit system, Explorer is a 64-bit process, so the pointer needs to be
a 64-bit field.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Nope, Windows XP, Version 2002, SP3

···

On Wednesday, September 17, 2014 10:54:46 AM UTC-7, Tim Roberts wrote:

Nathan McCorkle wrote:

Here’s my failed (at least currently) attempt at trying to change the

process name. This was adapted from some Visual Basic code I found

online. While it does change the process name in task manager, I don’t

think I’m converting the string correctly as the process name changes

to garbage or non-English characters.

Are you on a 64-bit operating system?

P.S. this is where I got VB code:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=66443&lngWId=1

Repasted the source files here:

prjTaskHider.vbp

https://bpaste.net/show/eba90dd1366e

mSharedMemory.bas

https://bpaste.net/show/12eba4a4e82f

mTask.bas

https://bpaste.net/show/ca3adf9d2bf7

frmTask.frm

https://bpaste.net/show/9deaf894dda5

···

On Wednesday, September 17, 2014 11:01:49 AM UTC-7, Nathan McCorkle wrote:

On Wednesday, September 17, 2014 10:54:46 AM UTC-7, Tim Roberts wrote:

Nathan McCorkle wrote:

Here’s my failed (at least currently) attempt at trying to change the

process name. This was adapted from some Visual Basic code I found

online. While it does change the process name in task manager, I don’t

think I’m converting the string correctly as the process name changes

to garbage or non-English characters.

Are you on a 64-bit operating system?

Nope, Windows XP, Version 2002, SP3