Function WAIntProc StdCall(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT Printf(!"hwnd = %#x, umsg = %d, wParam = %#x, lParam = %#x\n",hWnd, uMsg, wParam, lParam) Select Case uMsg Case WM_USER printf(!"WM_USER caught.\n") End Select End Function Sub InitKVIrcWinampInterface Alias "InitKVIrcWinampInterface" () Static WAWindow As HWND Dim As WNDCLASSEX WAClass Dim As ATOM a Dim As Dword WINERR With WAClass .cbSize = SizeOf(WNDCLASSEX) .style = 0 .lpfnWndProc = @WAIntProc .cbClsExtra = 0 .cbWndExtra = 0 .hInstance = GetModuleHandle(NULL) .hIcon = 0 .hCursor = 0 .hbrBackground = 0 .lpszMenuName = NULL .lpszClassName = @"Winamp v1.x" .hIconSm = 0 End With a = RegisterClassEx(@WAClass) printf(!"RegisterClassEx(&WAClass) returned %#x.\n", a) If a = 0 Then WINERR = GetLastError() Dim As ZString Ptr ErrMsg FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER Or FORMAT_MESSAGE_FROM_SYSTEM, 0, WINERR, 0, @ErrMsg, 256, 0) printf(!"Error %#x: %s\n", WINERR, ErrMsg) EndIf WAWindow = CreateWindowEx(0, "Winamp v1.x","PsyMP3 Winamp Interface Window - Winamp", _ 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(NULL), 0) printf(!"CreateWindowEx(...) returned %#x.\n", WAWindow) printf(!"FindWindow(\"Winamp v1.x\",NULL) returned %#x.\n", FindWindow("Winamp v1.x",NULL)) End Sub Sub ClearWMP() Dim cpd As CopyData Dim wmsg As WString * 500 Dim msgr As HWND Dim Found As Integer wmsg = "PsyMP3\0Music\00\0PsyMP3: Not playing\0\0\0\0\0" cpd.dwData = 1351 cpd.cbData = (Len(wmsg) * 2) + 2 cpd.lpData = @wmsg Do msgr = FindWindowEx(HWND_MESSAGE, msgr,"MsnMsgrUIManager", 0) If msgr = 0 Then Do msgr = FindWindowEx(0, msgr,"MsnMsgrUIManager", 0) If msgr = 0 Then If Found = 0 Then Printf(!"Cannot find messenger for announce!\n") Exit Do, Do EndIf SendMessage(msgr, WM_COPYDATA, 0, @cpd) Found = 1 Loop EndIf SendMessage(msgr, WM_COPYDATA, 0, @cpd) Found = 1 Loop End Sub Sub AnnounceWMP(artist As String, Title As String, Album As String) Dim cpd As CopyData Dim msgr As HWND Dim Found As Integer Dim wmsg As WString * 500 Dim As WString * 30 WMContentID = "WMContentID" Dim As WString * 500 MSNMusicString = !"PsyMP3\\0Music\\0%d\\0%s\\0%s\\0%s\\0%s\\0%s\\0" Dim As WString * 100 FormatStr = "PsyMP3: {1} - {0}" Dim As WString * 500 WTitle, WArtist, WAlbum MultiByteToWideChar(CP_UTF8, 0, StrPtr(artist), Len(artist), WArtist, Len(artist)) MultiByteToWideChar(CP_UTF8, 0, StrPtr(Title), Len(Title), WTitle, Len(Title)) MultiByteToWideChar(CP_UTF8, 0, StrPtr(Album), Len(Album), WAlbum, Len(Album)) wsprintfW(wmsg, MSNMusicString, 1, FormatStr, WTitle, WArtist, WAlbum, WMContentID) cpd.dwData = 1351 cpd.cbData = (Len(wmsg) * 2) + 2 cpd.lpData = @wmsg Do msgr = FindWindowEx(HWND_MESSAGE, msgr, "MsnMsgrUIManager", 0) If msgr = 0 Then Do msgr = FindWindowEx(0, msgr,"MsnMsgrUIManager", 0) If msgr = 0 Then If Found = 0 Then Printf(!"Cannot find messenger for announce!\n") Exit Do, Do EndIf SendMessage(msgr, WM_COPYDATA, 0, @cpd) Found = 1 Loop EndIf SendMessage(msgr, WM_COPYDATA, 0, @cpd) Found = 1 Loop End Sub