Reply to topic

Musicmatch "Now Playing" Script
Kay Klutchko


Joined: 25 Sep 2007
Posts: 16
Reply with quote
In the Tutorial for Musicmatch Jukebox "Now Playing", the following script is included:

However, when I attempt to run this script, I get an error message in the analyzer, saying: "undeclared variable or function 'StringEx';Line 31", which refers to this line:
StringEx szParse = szItemText;

I'm afraid I'm no good at this stuff, can anyone help me correct this script?

Thank you!
Kay


/ Look for MusicMatch Jukebox's playlist
// manager window

Window win = Window.FindByName("PlayListMgr");
if (win.GetHandle() == null) Script.Exit();

// The first child on this window is the
// ListView control containing track titles

Window winChild = win.GetChild();

// Attach to Gizmo spy control

CtrlList list = CtrlList.AttachFromWindow(
winChild.GetHandle());

// Monitor list, wait for a new item

int nLastSel = 0;

while (true)
{
int nNewSel = list.GetSelection();

if (nLastSel != nNewSel)
{
if (list.GetItemCount() != 0)
{
String szItemText = list.GetItemText(nNewSel,2);


StringEx szParse = szItemText;
int nFirstSpace = szParse.Find(" ");
int nByPos = szParse.Find(" by ");

String szTrackNum = szParse.Left(nFirstSpace);
StringEx szPad = szTrackNum;
szPad.PrePad("0",2);
szTrackNum = szPad.Mid(0);

String szSong = szParse.Mid(nFirstSpace + 3,
nByPos - (nFirstSpace + 3) - 1);
String szArtist = szParse.Right(szParse.GetLength() -
nByPos - 4);

Gizmo.WriteDesktop("$speed3$plain Now playing $b " +
szSong + " $plain by $b " + szArtist +
" $plain (Track #" + szTrackNum + ") $pause4 ");
}

nLastSel = nNewSel;
}

Script.Sleep(5000); // Wait a second
}
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
Hi Kay,

It looks like this article needs updating. Thank you for bringing this up.

StringEx was deprecated in v2.0.20. Just change 'StringEx' to 'String' on the line you highlighted, and also on the line where it reads: StringEx szPad = szTrackNum; After that, the script should run. Just be sure that MusicMatch is running before the script is executed, and you should be good to go!

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Kay Klutchko


Joined: 25 Sep 2007
Posts: 16
Reply with quote
Thank you! That string fix removed all errors. I haven't been able to get the "Now Playing" box to come up though. Is there anything that has to be set in Musicmatch Jukebox in order for this to work?
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
Hmmm, if you are using Windows Vista, then Gizmo might need to run as Administrator in order for the script to work properly. Otherwise the security features in Vista could keep Gizmo from communicating with MusicMatch. (If MusicMatch is running as Administrator and Gizmo is not)

On the other hand, if you are using WindowsXP (or Windows 2000) then the script should work as is. Just be sure that MusicMatch is running before the script is executed.

As soon as you run it, the script should show you something right away!

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Kay Klutchko


Joined: 25 Sep 2007
Posts: 16
Reply with quote
Silly me. I was starting Musicmatch first, but apparently I wasn't giving it long enough to run through it's complete startup procedure. Once I gave it the time to completely load up, the script worked just fine. Just a question though, is there a way to make it show the song info only one time? It shows about 3 or 4 times before the box fades out.
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
It sounds like the script is running more than once. Each instance of that script is telling you that the song changed. Smile To stop the scirpts, close Gizmo (right-click on the life preserver, then select 'Close Gizmo') Then try to run the script only once, OR make the script smart enough to start only once by adding this line to the top:

Script.Confine("{4DBFC7F1-3ADE-49fc-AE05-521695DD1F12}");

This lines checks to make sure that no other scripts are running with this GUID. If there are any, it terminates them and then continues running the script!

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Kay Klutchko


Joined: 25 Sep 2007
Posts: 16
Reply with quote
I added the line at the beginning of the script, and it works perfectly! Thanks! Very Happy
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
Sure thing! I should probably include that in the article, too. Glad it's working!

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Musicmatch "Now Playing" Script
All times are GMT - 8 Hours  
Page 1 of 1  

  
  

 Reply to topic