AndrewNohawk
Coding

MusicBee Plugin for mIRC

MusicBee

IF YOU DONT CARE ABOUT WHAT HAPPENED AND JUST WANT THE PLUGIN CLICK HERE
So i have recently switched over to the wonderful musicBee ( www.getmusicbee.com ), phenomenal application, nearly amarok for windows :) Some of the features i like:

  • Quick search (type in the search bar, library adjusts by searching all available fields intelligently)
  • Notifications across MSN and Last.fm and the like
  • Fantastic tagging per track and per album
  • Downloading of art and lyrics
  • Looks good :P

One of the features i have always used in my previous media players has been the now-playing-plugin for mIRC which i use on this machine.

Unfortunately i could not find any for musicBee, so yesterday i took a few hours to figure out how to make one.Let me preface this section by saying the last time i coded C++ was around 5 years ago at university, so i could be horribly wrong for some of this, but i’m just saying what i saw – also if the code is horrid, well, atleast it works :)

mIRC and DLLs

Essentially mIRC communicates with dll’s by calling the DLL ( which you specify ), the function within the DLL and some data that is sent from mIRC as per the documentation (mIRC help) the function looks as follows:

The routine in the DLL being called must be of the form:
int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

*my function was showSong

All DLLs also require a sort of reference file that tells mIRC exactly what functions are available like so:

LIBRARY "musicBeePlugin"
EXPORTS
showSong @ 1

* showSong is the function i created

Essentially i followed this guide to get setup, fantastic little how-to setup a mIRC plugin in VC++: http://purplespore.com/main/?p=46 and for just the guide: http://purplespore.com/main/wp-content/uploads/2008/10/mytutorial3.html

MusicBee and Songs

So after doing that i noticed that musicBee displays the current artist and song within the window title ie:

Alt Tab  - MusicBee

Alt Tab – MusicBee

Code

So now i just had to write some simply code to go through all the currently available windows and then find the one that matches “MusicBee”. Sure i could have used regular expressions, but i didnt wanna push my very limited C++ skills to get this done by overcomplicating something. None the less the code looks like this:

#include <windows.h>
#include <string>
using namespace std;
string finaldata = "";

BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
char buff[255];
if (!hWnd)
{
return TRUE; // Not a window
}
if (!::IsWindowVisible(hWnd))
{
return TRUE; // Not Visible?
}
GetWindowText(hWnd, buff, 255);
string windowTitle = buff;
string windowToFind = "- MusicBee";
basic_string <char>::size_type titlePos;
titlePos = windowTitle.find(windowToFind);
if(titlePos != string::npos)
{
finaldata += windowTitle.substr(0,titlePos);
}
return TRUE;
}

int __stdcall showSong(HWND mWnd,HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
EnumWindows(MyEnumProc, 0);
strcpy(data,finaldata.c_str());
return 3;
}

Some of the things that had me stuck:

SWITCH YOUR APP TO MULTIBYTE SUPPORT or you cannot use the char within GetWindowText — to do this:

  • Select project (not solution)
  • Project->properties
  • Character set->Use Multibyte Character Set
projectProperties

VC++ Project Properties

Download and Use

musicBeePlugin for mIRC — download .zip

Extract the above zip into your mirc directory, and add this to the alias file ( alt + r, click Aliases ).

/F4 //me is listening to: $dll(“musicBeePlugin.dll”,showSong,a) [ MusicBee ]

You can then press F4 to have your song playing:

mIRC with nowPlaying and Aliases

mIRC with nowPlaying and Aliases

Comments

  1. Nice, it works fine on AdiIRC (free mIRC alternative) last version, even on x64 if you compile for that.

    Thanks for sharing the source.

  2. Any clue why I get * $dll: unable to open ‘C:\Users\Mike\AppData\Roaming\mIRC\“musicBeePlugin.dll”’ every time I try to use this script?

  3. Mike:
    Most likely you copied the .dll into the wrong directory. If you copied to the mirc program directory (program files\mirc\) it will give you this error. It is looking for the .dll file at the location you posted….

    C:\Users\Mike\AppData\Roaming\mIRC\
    Browse to this location in windows explorer (windows key+e) and paste the file here. :)

  4. Thanks for sharing! I had an issue with it, then I read closely what your code did. It only works when MusicBee is opened on taskbar, since the code searches opened windows.
    Curiously, can you also get this to work for when MusicBee is minimized to tray? Thanks for sharing and the time you took to create the dll. :)

  5. I noticed when i used this code as described in the description:
    /F4 //me is listening to: $dll(“musicBeePlugin.dll”,showSong,a) [ MusicBee ]

    Does not work but returns an error:
    * $dll: unable to open ‘G:\mIRC\“musicBeePlugin.dll”’ (line 22, aliases.ini)

    This is because of the quotations around “musicBeePlugin.dll”….

    Remove the quotations! :D
    /np //say NP: $dll(musicBeePlugin.dll,showSong,a) [MusicBee]

Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *