• Welcome to Valhalla Legends Archive.
 

Winamp question

Started by Makaveli, December 14, 2003, 10:09 PM

Previous topic - Next topic

Makaveli

(Visual basic 6)
I read a few posts about winamp, and (unless I missed something) didn't come across any that explained or really gave any useful information on how I could have a bot skip to a specific song, like .play *Song*, and it would skip to a song that matched that.  If anybody could give me a few steps in the right direction or something I would appreciate it

iago

I posted this awhile back. It's in C++, so it needs to be converted, but that shouldn't be too hard.  Also, I know it's crappy code, but You'll Get Over It.

//Winamp.h

//This header controls the easier aspects of winamp, such as
//changing songs, fast forwarding, rewinding, etc.

//to use it, call the function with the string command, which
//is a Null-Terminated string which should match to one of the
//commands I've written.

//ffwd and rwnd are special because they can take an optional
//parameter.  If they are passed "rwnd 4" or "ffwd 5" (any number
//from 1 to 9) it will fast forward 5 seconds that many times.
//4 will fast foward 20 seconds, 9 will go 45, 1 will go 5, etc)

//Written by: Ron <[email protected]>

#define WS_PREV 40044
#define WS_NEXT 40048
#define WS_PLAY 40045
#define WS_PAUSE 40046
#define WS_STOP 40047
#define WS_FFWD 40060
#define WS_RWND 40061

inline char *WinampSong()
{
   // Returns the current song, or null for error
   static char title[256];

   title = NULL;

   if(GetWindowText(FindWindow("Winamp v1.x", NULL), title, 255) && title)
      if(strlen(title) > 9)
         title[strlen(title) - 9] = '\0';
   
   return title;
}

bool Winamp(unsigned int Command)
{
   //A return value of true indicates good
   //0 means bad


   if(!FindWindow("Winamp v1.x", NULL))
   {
      DisplayOnScreen("Winamp not found.");
      return true;
   }
   switch(Command)
   {
   case 0x00070250: // prev
      Command = WS_PREV;
      break;
   case 0x00073e3e: // next
      Command = WS_NEXT;
      break;
   case 0x0007f7b0: // play
      Command = WS_PLAY;
      break;
   case 0x00624360: // pause
      Command = WS_PAUSE;
      break;
   case 0x00076833: // stop
      Command = WS_STOP;
      break;
   case 0x00063106: // ffwd
      Command = WS_FFWD;
      break;
   case 0x00062902: // rwnd
      Command = WS_RWND;
      break;
   case 0x00061883: // song
      {
         char *WASong = WinampSong();

         DisplayEx("Now playing: %s", (WASong && *WASong) ? WASong : "Winamp not found!");
         return TRUE;
         break;
      }
   default:
      return FALSE;
   }


   SendMessage(FindWindow("Winamp v1.x", NULL), WM_COMMAND, Command, NULL);

   return TRUE;
}



void DisplaySongIfChanged()
{
   char *CurrentSong = WinampSong();

   if(CurrentSong)
   {
      if(strcmp(g_WinampSong, CurrentSong))
      {
         // If the song has changed
         DisplayEx("Now Playing: %s", CurrentSong);
         strcpy(g_WinampSong, CurrentSong);
      }
   }
}
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*