Page 1 of 1

Looking for help improving my first script

Posted: Thu Apr 04, 2013 5:26 pm
by m42i
Hello fellow developers,

I've written my first script for MM 4.0 (didn't use MM before). "Quizzor" is a script to help performing a music quiz with friends. More details at the project's page: http://github.com/m42i/Quizzor

The forum and wiki were a good resource, but there are some things I couldn't figure out. I thought about making one topic for each problem, but I don't want to spam the forums just now. ;)

Here are my difficulties:
- Resize ActiveX and Trackbar element when the persistent dockable panel is resized
I tried the OnResize event, but that won't trigger when resizing the panel. I also played a lot with Anchors, Align, SetRect, SetRectClient, but I just can't figure out how everything works together.

- Hide vertical scrollbar of ActiveX control and/or only show when needed. Is it even possible?

- Automatically hide Now Playing List, Player and "Image and Detail" window
This would be nice, but getting the current visible state of each would be ok too.

- Change playback time, when TrackBar is changed
I tried OnChange event, but that is also triggered when my Timer changes the TrackBar. OnClick and Mouse events don't seem to work at all.

- Automatically select newly created playlist
I think I could get this to work by iterating through all playlists and finding the correct one if there isn't a shortcut.

Any help is appreciated,
masi

Re: Looking for help improving my first script

Posted: Fri Apr 05, 2013 6:54 am
by rovingcowboy
Don't know exactly what you are trying to do can you break it into one item at a time for us part time script writers thanks ? :D

Re: Looking for help improving my first script

Posted: Sat Apr 06, 2013 6:03 am
by trixmoto
m42i wrote:- Resize ActiveX and Trackbar element when the persistent dockable panel is resized
I tried the OnResize event, but that won't trigger when resizing the panel. I also played a lot with Anchors, Align, SetRect, SetRectClient, but I just can't figure out how everything works together.
Yes, I think using Anchors should allow you to do this, probably just anchored to the left and right. It's hard to say without a more specific example though.
m42i wrote:- Hide vertical scrollbar of ActiveX control and/or only show when needed. Is it even possible?
I believe you can do this within the stylesheet or <style> tag in the html content. Some of the skins for my MonkeyRok script do this, I think.
m42i wrote:- Automatically hide Now Playing List, Player and "Image and Detail" window
This would be nice, but getting the current visible state of each would be ok too.
These details will either be stored in MediaMonkey.ini or the registry, so you can definitely get the visible state. I can't see any API methods to control them though.
m42i wrote:- Change playback time, when TrackBar is changed
I tried OnChange event, but that is also triggered when my Timer changes the TrackBar. OnClick and Mouse events don't seem to work at all.
I thought my Previewer script did this, but I've checked and it doesn't, so I probably had the same problems. It uses buttons instead, and uses a TrackBar for display only.
m42i wrote:- Automatically select newly created playlist
I think I could get this to work by iterating through all playlists and finding the correct one if there isn't a shortcut.
Iterating through the playlists is the way that my scripts do this, including TagCloud and SimilarArtists.

Re: Looking for help improving my first script

Posted: Sat Apr 06, 2013 11:24 am
by m42i
Thank you, trixmoto. I'll have a look at your scripts.
trixmoto wrote:
m42i wrote:- Automatically hide Now Playing List, Player and "Image and Detail" window
This would be nice, but getting the current visible state of each would be ok too.
These details will either be stored in MediaMonkey.ini or the registry, so you can definitely get the visible state. I can't see any API methods to control them though.
I played a bit with the ini file. In particular with the Apply method according to this wiki page. That changes the ini file, but doesn't apply the change.

Re: Looking for help improving my first script

Posted: Sat Apr 06, 2013 12:50 pm
by m42i
trixmoto wrote:
m42i wrote:- Automatically select newly created playlist
I think I could get this to work by iterating through all playlists and finding the correct one if there isn't a shortcut.
Iterating through the playlists is the way that my scripts do this, including TagCloud and SimilarArtists.
I looked at your scripts and the wiki, but couldn't find a way to make the node selected. SDB.MainTree.Node_Playlists gives a TreeNode object, but only TreeListItem seems to have a Selected property.

Re: Looking for help improving my first script

Posted: Thu Apr 11, 2013 3:51 am
by trixmoto
You set SDB.MainTree.CurrentNode to equal the TreeNode object of the node you want selected. My TagCloud script embeds a function into the panel like this...

Code: Select all

Dim tree : Set tree = SDB.MainTree
Dim node : Set node = tree.Node_Library
Dim i : i = 0
Dim l : l = UBound(arr)
For i = 0 To l
  Dim c : c = arr(i)
  If i < l Then
    c = SDB.Localize(c)
  Else
    c = c&"" (""
  End If
  node.Expanded = True
  Set node = tree.FirstChildNode(node)
  Dim n : n = node.Caption
  If i = l Then
    n = Left(node.Caption,Len(c))
  End If
  If (i = l) And (map) Then
    n = MapXML(n)
  End If
  Do While ((n <> c) Or (node.Visible = False))      
    node.Expanded = False
    Set node = tree.NextSiblingNode(node)
    If Err.Number <> 0 Then
      Err.Clear
      Exit Function
    End If
    If i = l Then
      n = Left(node.Caption,Len(c))
    Else
      n = node.Caption
    End If
    If (i = l) And (map) Then
      n = MapXML(n)
    End If        
  Loop
Next
SDB.ProcessMessages
tree.CurrentNode = node '<----- this is where it selects the node that you've found
node.Expanded = True

Re: Looking for help improving my first script

Posted: Sun Jun 02, 2013 4:27 am
by Andreas Weichert
Hello !
A very interesting project your Quizzor. I looked in your very clear structured and clean code.
(Maybe you can integrate some object-orientated concepts to make it shorter.)
A public simple mmip setup-file for would be nice. Everybody is lazy or maybe doesnt know how it integrate your script.

To your seekbar:
The GUI possibilities are very restricted in MM. The integrated seekbar has no absolute seek with the mouse clicks but only a increment/decrement. So I decided in my script to simulate a seeker with a panel and ASCII-characters. Unfortunatel MM supports no custom colored panel.
It works and looks good. Take a look in my Multi-Previers.
If you take a "_" character you can create a not interruped seekbar.