Expanding certain nodes in the filebrowser at startup

Répondre

Émoticônes
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

Le BBCode est activé
La balise [img] est activée
La balise [url] est activée
Les émoticônes sont activées

Relecture du sujet
   

Agrandir Relecture du sujet : Expanding certain nodes in the filebrowser at startup

par Steegy » jeu. janv. 12, 2006 10:42 am

A forum post for the complete script can now be found here:
http://www.mediamonkey.com/forum/viewtopic.php?t=7490

Cheers
Steegy

par gozzer » dim. janv. 01, 2006 7:14 pm

The latest changes you posted worked like a charm! For some reason I had to add the SDB variable to the contruction list to avoid error messages.

All though I can't understand why it suddenly needed to be constructed, it now works great!

Thank you once again :)

Edit: the problem with the C:\ disc appearing twice in the list, is also gone.

par Steegy » dim. janv. 01, 2006 6:04 pm

OK

Change the onStartup code to:

Code : Tout sélectionner

Sub onStartUp 

  Set SDB = CreateObject("SongsDB.SDBApplication")
  WScript.Sleep 1000

  ChooseMore SDB.MainTree.Node_MyComputer,"D:\ [Media]" & sN & "Music"

End Sub 
and add the following line just after it:

Code : Tout sélectionner

Call onStartUp
Then move the file from the Scripts\Auto folder to the Scripts folder.

In the Scripts\Auto folder, make a script "StartupNodeStarter.vbs" with the following contents:

Code : Tout sélectionner

'################################################################################
'# This script is part of the StartupNode script.                               #
'# It's an Autostart script and should be in MediaMonkey's Scripts\Auto folder. #
'################################################################################

Sub OnStartup 
  Dim WShell, Command, Result 
  Set WShell = CreateObject("WScript.Shell") 
  Command = Chr(34)&SDB.ApplicationPath&"Scripts\StartupNode_v1.0.vbs"&Chr(34) 
  Result = WShell.Run(Command, 1, 1)   
End Sub 
Explanation: the Starter script is started by MediaMonkey on startup, and runs the StartupNode script (now in the Scripts folder). This is now an external script and can use Wscript's sleep methode to freeze execution for 1000 ms = 1 s. This normally is enough time for the "My Computer" node to be loaded so that the script can use it.

Cheers
Steegy

par Steegy » dim. janv. 01, 2006 5:32 pm

OK, my fault I didn't try this version of the script (I actually adapted from an older script of mine).

The problem is that the "My Computer" tree node hasn't yet been made when the script is run on startup. That's why it can't find the specified node.
If you e.g. put

Code : Tout sélectionner

SDB.MessageBox "You are welcome!", mtError, Array(mbOk)
in the beginning of the OnStartup Sub, the program has time to build it's "My Computer" node while the error box is shown. After that you click OK, the script continues and works like it should.

So to slow down the script, I think the best way would be to delay it's execution, but that will have to be done using an external script.
I'll post that when it's made.

Cheers
Steegy

par gozzer » dim. janv. 01, 2006 2:30 pm

Hello again, and happy new year I might add :-)

I'm still having problems with browsing my way through "My Computer" after a bit of reading and trial & error. I've tried pretty much every name combo I can think of now, with no luck.

I've also tried to "escape" the backslash with another (and two) backslash(es), but this did not make any difference. Fair to say, I am not much of a VB guy ;)

About the crashing MM issue. It's not so much crashing, as MM itself just hangs during startup and keeps the CPU load at ~100%. I get no error messages, the program just fails to initate itself propery (stops some time during the splash screen). This happens whenever I use a value other than "" with the Node_MyComputer.

Thanks again.

par Steegy » sam. déc. 31, 2005 12:33 pm

Hello


Please read the last post in http://www.mediamonkey.com/forum/viewtopic.php?t=6924. There, it's explained how to open a Location node (similar to My Computer node).

BTW: According to your screenshot, you need:

Code : Tout sélectionner

ChooseMore SDB.MainTree.Node_MyComputer,"D:\ [Media]" & sN & "Music" 
to open the node D:\Music

(The script reads the text on a node when it travels through to open one of them. That means that you need to give the script the right text, and that's the text you see in the MediaMonkey tree.)

About the crashing: when using the right syntax (as said above), the script shouldn't crash. If it crashes, I hope it's only this script and not whole MediaMonkey.

The Card reader and the duplicate disk you have in the tree shouldn't be a problem for the script. If this duplicates problem persists, you'd better post it in the "Bugs" forum.

Cheers
Steegy

par gozzer » sam. déc. 31, 2005 10:17 am

Hi Steegy, and thank you for your reply.

The script you showed me did exactly what I need, but I ran into a problem :-)

The command for expanding the playlists node worked great, but I could not figure out how to browse my way down one of my harddrives.

I've attached a screenshot of the file browser as it looks right after startup.
I've used the following code:
ChooseMore SDB.MainTree.Node_Playlists,""
ChooseMore SDB.MainTree.Node_MyComputer,""

I tried the following code a few times, but it crashed MM:
ChooseMore SDB.MainTree.Node_MyComputer,"D:\" & sN & "Music"


Thank you for all your help!

Pic: Image

par Steegy » sam. déc. 31, 2005 9:01 am

Hello

Please read "Starting MM Where You Left Off" http://www.mediamonkey.com/forum/viewtopic.php?t=6924
Maybe this will suit your needs.

The script is made to browse to a specific node on startup. I guess you can browse to 2 nodes after each other (by using 2 ChooseMore calls in the OnStart sub) so they are both expanded.

If you don't understand something or need additional help, feel free to ask!

Cheers
Steegy

Expanding certain nodes in the filebrowser at startup

par gozzer » sam. déc. 31, 2005 7:27 am

I was wondering if there was a way to expand some of the nodes in the file tree at startup. For instance, I would like to have c:\somefolder\important_folder visible whenever MediaMonkey starts up.

They way things are set up now, I have to manually browse to this location for each session. This also applies to the Playlist-node. It would be great to have this expanded too.

Thanks for your time :-)

Haut