Monday, May 12, 2008

Python Winamp Control Module

As expected, I'm posting my iWC's Winamp control module here.

The module works without the need of installing a plugin in Winamp, hence it does alot of IPC (some of it is totally undocumented, and I think that even Winamp's developers didn't think of using their media library in such a way, but who cares).

All of the functions are documented beside of the three most complicated ones, because I'm just too lazy - so if you're really interested I can spread some lights on the ugly hacks I did too.

Get it from here.

Requirements: ctypes, win32 python modules (comes with ActiveState's python), Winamp 5+.

Feature request / comments - just leave a comment here.

Have fun!


Anonymous said...

any reason that queries may not work on some computers? works on my laptop, but not on my desktop for some reason... query just returns []

StatusReport said...

What version of Windows / Winamp do you use on both?

Also, just to verify it's not a security issue try to run the script as Administrator.

Aritra Das said...

I am using
Winamp 5.63
Windows 7 ultimate x64 with sp1
python 2.7 x64
I can get status of winamp, get playlist items and play pause but queries return empty lists[] and enqueueFile doesn't work. Nothing gets enqueued. I have tried running it from administrator mode command prompt. No change. Any idea why?

StatusReport said...

I'm highly confident that the problem stems from the fact you're using Python x64 instead of x86. The features you mentioned use low-level IPC that may be broken (with the current implementation) on x64 processes.

I use the same Winamp version with Python 2.7 x86 and it works correctly.

Aritra Das said...

Okay, I tried with python 2.7 x86
No change.

Aritra Das said...

oh.. sorry. I forgot administrator mode.. So now it works with admin mode and python x86
One last quick question:
How do I get Python to always run in admin mode. Is there a way for me to permanently grant admin permission to python?

StatusReport said...

Good to hear it's working.
Basically, if your user is a local administrator it should suffice (no need to explicitly run Python as an administrator). If not, another option is to add the user to the 'Power Users' group, which is a more limited group than the 'Administrators' group but should suffice for the remote process memory stuff that is going on PyWinamp.
Last, if you don't want to grant these permissions you can set Python to run as admin (via right click -> properties), but then you'll have to accept the UAC dialog each time you run it, or disable UAC completely.

When I skimmed the code now, I suspect that it's possible that administrator permissions are not required for the read/write operations, but code modifications needs to be done. I'll add this to my TODO list and will post a comment here if that's indeed the case.

Zmaj said...

Can you port this to Python3? I'm getting syntax errors:

>File "", line 187
>except pywintypes.error, e:
> ^

I'm using Python33 x86 and Win7 x64

I also tried adding
#!c:/Python27/python.exe -u
to switch to python versions, but I still had errors.

When I tried just removing the
", e:" I was getting syntax errors in other places.