Any chance of coding something to work with this mess from the ljwin32 client?
Though, considering it is an open source client, it might just be better for someone to add native support for winamp_spam. This problem does not really concern me, I just happen to have an older copy of the source code lying around on my drive.
// gets playing music from WinAmp or MediaPlayer, and returns
BOOL CPostOptionsDlg::GetPlayingMusic(CString &song)
{
// is WinAMP open?
HWND hwindow = ::FindWindow("Winamp v1.x",NULL);
if (hwindow == NULL) {
// sonique perhaps?
hwindow = ::FindWindow("Sonique Window Class",NULL);
if (hwindow == NULL) {
// freeamp there?
hwindow = ::FindWindow("FreeAmp",NULL);
if (hwindow == NULL) {
// is MediaPlayer open?
hwindow = ::FindWindow("Media Player 2",NULL);
if (hwindow == NULL) {
// what about CD player?
hwindow = ::FindWindow("MMFRAME_MAIN",NULL);
if (hwindow == NULL)
return FALSE;
else
song = GrabPlaying(hwindow, "- CD Player", 11, 4);
}
else
song = GrabPlaying(hwindow, "- Windows Media Player", 22, 3);
}
else
song = GrabPlaying(hwindow, "FreeAmp: ", 9, 2);
}
else
song = GrabPlaying(hwindow, "- sonique", 9, 1);
}
else
song = GrabPlaying(hwindow, "- Winamp", 8, 0);
return TRUE;
}
// which description
// 0 -- Winamp
// 1 -- Sonique
// 2 -- FreeAmp
// 3 -- Media Player 6
// 4 -- Windows CD Player
CString CPostOptionsDlg::GrabPlaying(HWND win, CString match, int length, int which)
{
CString song = "";
CString msg = "";
if (which == 0) {
// in WinAMP playing?
int ret = ::SendMessage(win, WM_USER, 0, 104);
if (ret != 1)
return song;
}
// let's go find the titlebar
char this_title[2048],*p;
::GetWindowText(win,this_title,sizeof(this_title));
p = this_title+strlen(this_title)-length;
while (p >= this_title)
{
if (!strnicmp(p,(LPCTSTR)match,length))
break;
p--;
}
if (p >= this_title)
p--;
while (p >= this_title && *p == ' ')
p--;
// do application specific stuff
int numhead = 0;
switch (which) {
case 0:
// this is winamp
*++p=0;
char *iter, *start;
start = this_title;
iter = start;
// remove leading s/^\d+\. //;
while (*iter) {
if (isdigit(*iter)) {
iter++;
numhead++;
}
else
break;
}
if (numhead && *iter=='.' && *(iter+1)==' ') {
start = iter+2;
}
song = start;
break;
case 1:
// this is sonique
song = this_title;
song = song.Mid((song.Find((LPCTSTR)".mp3", 0)+7), song.GetLength());
break;
case 2:
// this is freeamp
song = this_title;
song = song.Mid(length, song.GetLength());
break;
case 3:
// this is media player 6
p -= 3;
// is it actually playing an mp3?
if (!strnicmp(p, ".mp3", 4))
*p=0;
else
return song;
song = this_title;
break;
case 4:
// this is windows cd player
*++p=0;
song = this_title;
if (song == "Please insert an audio compact disc")
song = "";
break;
}
return song;
}