T
The Collector
Hi,
I've been looking for almost two full days now to get full control of
WinAMP using python. Simple play/stop functions are no problem. It's
the WM_COPYDATA that's used by IPC_PLAYFILE (=add a file to the
playlist) that's giving me troubles big time!
My latest test code:
---------------------------------------
from win32gui import FindWindow
from win32api import SendMessage
import struct
import array
WM_USER = 0x400 # WM-ID for
a WinAMP user command
WM_COPYDATA = 0x004A # WM-ID for
a WinAMP copyData command
IPC_PLAYFILE = 100 # WM-ID for
WinAMP to add item to WinAMP playlist
hWnd = FindWindow('Winamp v1.x', None) # Find the
WinAMP window-handle (receiver)
def packData( dwData, lpData ):
lpData_ad = array.array('c', lpData).buffer_info()[0] # calculate
the pointer address for the lpData
cbData = array.array('c', lpData).buffer_info()[1] # calculate
the length of the lpData (=cbData)
cds = struct.pack("IIP", dwData, cbData, lpData_ad) # pack
dwData, cbData and lpData into a copyDataStruct
cds_ad = array.array('c', cds).buffer_info()[0] # find the
pointer address of the copyDataStruct
return cds_ad # return
the copyDataStruct pointer-address
def addItemToPlaylist( item ):
uInt = IPC_PLAYFILE # ID for
adding an item to the WinAMP playlist
wParam = 0 # Not
defined (leave at zero)
lParam = packData( uInt, item ) # create
the copyDataStruct-pointer
SendMessage( hWnd, uInt, wParam, lParam ) # Send the
data to the WinAMP window
file = r"C:\Party Animals - Atomic.mp3"
addItemToPlaylist( file )
---------------------------------------
the code runs fine, no errors, but nothing happens!! I've already had a
test in which garbage was added to the playlist, but that's it...
Anybody, any ideas on the problem? tnx...
I've been looking for almost two full days now to get full control of
WinAMP using python. Simple play/stop functions are no problem. It's
the WM_COPYDATA that's used by IPC_PLAYFILE (=add a file to the
playlist) that's giving me troubles big time!
My latest test code:
---------------------------------------
from win32gui import FindWindow
from win32api import SendMessage
import struct
import array
WM_USER = 0x400 # WM-ID for
a WinAMP user command
WM_COPYDATA = 0x004A # WM-ID for
a WinAMP copyData command
IPC_PLAYFILE = 100 # WM-ID for
WinAMP to add item to WinAMP playlist
hWnd = FindWindow('Winamp v1.x', None) # Find the
WinAMP window-handle (receiver)
def packData( dwData, lpData ):
lpData_ad = array.array('c', lpData).buffer_info()[0] # calculate
the pointer address for the lpData
cbData = array.array('c', lpData).buffer_info()[1] # calculate
the length of the lpData (=cbData)
cds = struct.pack("IIP", dwData, cbData, lpData_ad) # pack
dwData, cbData and lpData into a copyDataStruct
cds_ad = array.array('c', cds).buffer_info()[0] # find the
pointer address of the copyDataStruct
return cds_ad # return
the copyDataStruct pointer-address
def addItemToPlaylist( item ):
uInt = IPC_PLAYFILE # ID for
adding an item to the WinAMP playlist
wParam = 0 # Not
defined (leave at zero)
lParam = packData( uInt, item ) # create
the copyDataStruct-pointer
SendMessage( hWnd, uInt, wParam, lParam ) # Send the
data to the WinAMP window
file = r"C:\Party Animals - Atomic.mp3"
addItemToPlaylist( file )
---------------------------------------
the code runs fine, no errors, but nothing happens!! I've already had a
test in which garbage was added to the playlist, but that's it...
Anybody, any ideas on the problem? tnx...