Looking for help improving my first script

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

Looking for help improving my first script

Postby m42i » Thu Apr 04, 2013 5:26 pm

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
m42i
 
Posts: 9
Joined: Wed Apr 03, 2013 7:13 am

Re: Looking for help improving my first script

Postby rovingcowboy » Fri Apr 05, 2013 6:54 am

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
roving cowboy / keith hall. My skins viewtopic.php?f=9&t=16724 for some help check on Monkey's helpful messages at viewtopic.php?p=44008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
rovingcowboy
 
Posts: 14146
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)

Re: Looking for help improving my first script

Postby trixmoto » Sat Apr 06, 2013 6:03 am

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.
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

Re: Looking for help improving my first script

Postby m42i » Sat Apr 06, 2013 11:24 am

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.
m42i
 
Posts: 9
Joined: Wed Apr 03, 2013 7:13 am

Re: Looking for help improving my first script

Postby m42i » Sat Apr 06, 2013 12:50 pm

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.
m42i
 
Posts: 9
Joined: Wed Apr 03, 2013 7:13 am

Re: Looking for help improving my first script

Postby trixmoto » Thu Apr 11, 2013 3:51 am

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
Download my scripts at trixmoto.net.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE
trixmoto
 
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK

Re: Looking for help improving my first script

Postby Andreas Weichert » Sun Jun 02, 2013 4:27 am

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.
My Scripts
Take a look on my Android app Time Sheriff – the extensive all-in-one timer/reminder.
Andreas Weichert
 
Posts: 57
Joined: Fri Apr 05, 2013 4:51 am


Return to MediaMonkey 4 Addons developer forum

Who is online

Users browsing this forum: No registered users and 2 guests