Hi everyone.
I'm making integration with Stream Deck. I'm not creating a Stream Deck plugin, at least for now, so I won't be able to show statuses in the Deck and rather start simple.
I'm a Python programmer and that's also my language of choice.
So I successfully wrote some code to play/pause/stop/prev/next using win32api.SendMessage(hWinamp, win32con.WM_COMMAND, id, 0)
, where id is a given button.
I'd also like to be able to change playlists, but despite different attempts, nothing happens.
My sample code:
import win32api
import win32gui
import win32con
import sys
import ctypes
from ctypes import wintypes
# enumerates windows and returns possible matches
def window_enum_callback(hwnd, hwnds):
#hwnds = []
if 'Winamp' in win32gui.GetWindowText(hwnd) or 'WACUP' in win32gui.GetWindowText(hwnd):
hwnds.append(hwnd)
hwnds = []
win32gui.EnumWindows(window_enum_callback, hwnds)
return
# queries for a version to check if whatever has "winamp" in it's title is actually winamp
for hwnd in hwnds:
result = usercommand(hwnd, 0)
if result:
break
# data structore for a playlist path
class COPYDATASTRUCT(ctypes.Structure):
_fields_ = [
('dwData', wintypes.LPARAM),
('lpData', ctypes.c_void_p),
('cbData', wintypes.DWORD),
]
file = b'd:\\test.m3u8'
playlist = COPYDATASTRUCT(100, ctypes.cast(ctypes.c_char_p(file), ctypes.c_void_p), len(file)+1)
win32api.SendMessage(hWinamp, win32con.WM_COPYDATA, 0, playlist)
I'm also clearing up the playlist with code (which I did not include in at the above example, and this works).
I also tried:
win32api.SendMessage(hwnd, win32con.WM_USER, file, 100)
but this crashes Wacup.
Anyone have an idea what am I doing wrong?
Thanks,
Daniel