Right Click for Scripts -with buttons! (2008-09-07) [MM3]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by MoDementia » Tue Sep 02, 2008 6:48 pm

PS A refresh option would be nice instead of restarting MM :)

PPS
This

Code: Select all

	Dim iniMM: Set iniMM = sdb.IniFile
	If iniMM.BoolValue(SCRIPT_NAME, "Logging") = "" Then    'set it the first time we launch
		iniMM.BoolValue(SCRIPT_NAME, "Logging") = False
	End If
should be

Code: Select all

	Dim iniMM: Set iniMM = sdb.IniFile
	If NOT iniMM.ValueExists(SCRIPT_NAME, "Logging") Then    'set it the first time we launch
		iniMM.BoolValue(SCRIPT_NAME, "Logging") = False
	End If
PPPS
I accidently added a menu icon, but couldn't delete it as it was the only one except by editing the mediamonkey.ini?

PPPPS
Some code you might find useful

Code: Select all

  Set iniPP = SDB.Tools.IniFileByPath(iniPathedFileName)
  Set SectionsStringList = iniPP.Sections
  SectionCount = SectionsStringList.Count
  For xCounter = 0 to SectionCount - 1
    SectionName = SectionsStringList.Item(xCounter)
    filename = iniPP(SectionName,"filename")
    procname = iniPP(SectionName,"procname")
    displayname = iniPP(SectionName,"displayname")
    description = iniPP(SectionName,"description")
    scripttype = iniPP(SectionName,"scripttype")
    icon = iniPP(SectionName,"icon")
    submenu = iniPP(SectionName,"submenu")
    If Stuff is correct/matches then
      Add it to the array
    End If
  Next

onenonymous
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by onenonymous » Tue Sep 02, 2008 7:38 pm

MoDementia wrote:Not editing script file?

Specific sections Added to the menu but the lines (sub) are not added to the script (missing the last sorted item?)
I'm not clear on your question?
MoDementia wrote:PS A refresh option would be nice instead of restarting MM :)
I agree - but how would it be triggered? Is there an event that occurs when a new script is added?
MoDementia wrote:PPS
This

Code: Select all

	Dim iniMM: Set iniMM = sdb.IniFile
	If iniMM.BoolValue(SCRIPT_NAME, "Logging") = "" Then    'set it the first time we launch
		iniMM.BoolValue(SCRIPT_NAME, "Logging") = False
	End If
should be

Code: Select all

	Dim iniMM: Set iniMM = sdb.IniFile
	If NOT iniMM.ValueExists(SCRIPT_NAME, "Logging") Then    'set it the first time we launch
		iniMM.BoolValue(SCRIPT_NAME, "Logging") = False
	End If
Thanks - I'll add it to the next update.
MoDementia wrote:PPPS
I accidently added a menu icon, but couldn't delete it as it was the only one except by editing the mediamonkey.ini?
One of the updates I have coming is to add a Clear All to the button/menu builder form. As it is currently, there's no way to delete all buttons once you created any. You should be able to change them with the form, just can't delete that last one yet. It'll be fixed in the next update. :oops:

Thanks again for your comments.
~One

PS - you've been quite the code-machine lately. It's starting to look like you'll catch up to Trix in the number of scripts you've created! :)

onenonymous
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by onenonymous » Tue Sep 02, 2008 7:40 pm

MoDementia wrote:PPPPS
Some code you might find useful
Thanks!!!!! That certainly looks cleaner than the way I did it. :-? :)

MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by MoDementia » Tue Sep 02, 2008 7:43 pm

Although switchratings is added to the RCFS menu the actual switchratings.vbs isn't processed to add the extra lines of code.
PS It will only happen if the newest installed script is the last in the sorted list.
i.e. you can test it by adding a dummy "zzz" displayname entry and script.

Refresh, just add another option near the add toolbar / logging options (manually refresh when the user installs/uninstalls a script or edits the scripts.ini)

onenonymous
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by onenonymous » Tue Sep 02, 2008 7:56 pm

MoDementia wrote:Although switchratings is added to the RCFS menu the actual switchratings.vbs isn't processed to add the extra lines of code.
I recently changed some portions of my code with the statement "For xx = 1 to N" to now be "For xx = 0 to N-1" - I'm betting I missed updating the FixScript piece to catch that. I'm at work now without my scripts - so can't check though. Hopefully that's all this one is, if so, it'll be an easy fix.
MoDementia wrote:Refresh, just add another option near the add toolbar / logging options (manually refresh when the user installs/uninstalls a script or edits the scripts.ini)
Duh :-? easy enough. Sure wish there was an event though...

Thanks again for all your comments.

~One

MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by MoDementia » Tue Sep 02, 2008 8:14 pm

I'm not 100% sure if this will work but here is some additional code that includes the sort aswell

Code: Select all

  Set iniPP = SDB.Tools.IniFileByPath(iniPathedFileName)
  Set SectionsStringList = iniPP.Sections
  Set BubbleSortStringList = SDB.NewStringList
  SectionCount = SectionsStringList.Count
  For xCounter = 0 to SectionCount - 1
    SectionName = SectionsStringList.Item(xCounter)
    filename = iniPP(SectionName,"filename")
    procname = iniPP(SectionName,"procname")
    displayname = iniPP(SectionName,"displayname")
    description = iniPP(SectionName,"description")
    scripttype = iniPP(SectionName,"scripttype")
    icon = iniPP(SectionName,"icon")
    submenu = iniPP(SectionName,"submenu")
    If Stuff is correct/matches then
      BubbleSortStringList.Add displayname & "~~" & filename & "~~" & procname & "~~" & description & "~~" & scripttype & "~~" & icon  & "~~" & submenu
    End If
  Next
  BubbleSortStringList.Sort
  BubbleSortCount = BubbleSortStringList.Count
  ReDim mnuScript(BubbleSortCount)
  ReDim mnuProc(BubbleSortCount)
  ReDim mnuCaption(BubbleSortCount)
  ReDim mnuHint(BubbleSortCount)
  ReDim mnuType(BubbleSortCount)
  ReDim mnuIcon(BubbleSortCount)
  ReDim mnuSubMenu(BubbleSortCount)
  For xCounter = 0 to BubbleSortCount - 1
    tmpArray = Split(BubbleSortStringList.Item(xCounter),"~~",-1,1)
    mnuScript(xCounter) = tmpArray(1)
    mnuProc(xCounter) = tmpArray(2)
    mnuCaption(xCounter) = tmpArray(0)
    mnuHint(xCounter) = tmpArray(3)
    mnuType(xCounter) = tmpArray(4)
    mnuIcon(xCounter) = tmpArray(5)
    mnuSubMenu(xCounter) = tmpArray(6)
  Next

Kilmatead
Posts: 206
Joined: Mon Apr 07, 2008 2:16 pm
Location: Dublin

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by Kilmatead » Wed Sep 03, 2008 12:59 am

onenonymous wrote:Finally, I noticed yesterday that my code for parsing out scripts.ini assumes that the line with ScriptType=XX is the last line in the section. If ScriptType=XX wasn't last, then it might not work right as is - I'll fix that in an update. Until then, please make sure any scripts.ini updates you create have ScriptType=99 (or whichever number you use) as the last line in the section.
...and that would explain why my install was misbehaving. I just gave up and created the headers manually. Thanks for an hour of head scratching. :D

barkoz
Posts: 121
Joined: Fri May 02, 2008 5:58 pm
Location: Sydney, Australia

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by barkoz » Wed Sep 03, 2008 3:23 am

Would it be possible to get this to work with Case and Leading Zero Checker?
Thank's Mo, works a charm
:D :D :D

onenonymous
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by onenonymous » Wed Sep 03, 2008 8:15 am

MoDementia wrote:I'm not 100% sure if this will work but here is some additional code that includes the sort aswell
Genius!!! I look forward to giving this a try. :D

onenonymous
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by onenonymous » Fri Sep 05, 2008 6:20 pm

MoDementia wrote: 2. I wonder if we can flag an entry as a submenu and have subsequent entries added to it? Users could also arrange scripts this way Sub menu "Not Used Often", "Reports", "Tools" etc. by adding the extra information/section(s)

Code: Select all

[DEISync]
Filename=Auto\DEISync.vbs
Procname=
Order=85
DisplayName=DEISync Menu
Description=DEISync Menu
Language=VBScript
ScriptType=99
Icon=Scripts\View Manager\Icons\table_go.ico
SubMenu=Yes

[DEISync1]
Filename=Auto\DEISync.vbs
Procname=ExportCompleteDatabase
Order=0
DisplayName=Export Complete Database
Description=Export Complete Database
Language=VBScript
ScriptType=99
Icon=25
SubMenu=DEISync
So we could end up with this
Image
How bout something like this for Scripts.ini:

Code: Select all

[DEISync1]
Filename=Auto\DEISync.vbs
Procname=ExportCompleteDatabase
Order=0
DisplayName=DEISync Menu\Export Complete Database
Description=Export Complete Database
Language=VBScript
ScriptType=99
Icon=25

[DEISync2]
Filename=Auto\DEISync.vbs
Procname=ExportSyncDatabase
Order=0
DisplayName=DEISync Menu\ExportSyncDatabase
DividerBefore=True
Description=Export Sync Database
Language=VBScript
ScriptType=99
Icon=26
I could parse the DisplayName entry for the "\" (or maybe it should be "/"?). Then make a submenu for the first part of the DisplayName with the individual menu items coming next. Maybe also add an entry like "DividerBefore=True" if you wanted to put dividers in your submenu? Feedback?

Also, I want to thank you again for your recent code suggestions. I'm working on adding them into the code to release an update this weekend sometime.

~One

MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by MoDementia » Fri Sep 05, 2008 8:09 pm

I like the idea of a dividebefore and probably a divideafter would be useful so you could set the range of the diverders
Because if you want 1 before and 1 after you have to put a dividebefore on an option that may move when you add/delete a script.
But the sub menu group will either be there or not

Sub1
Divide before
Sub2
Sub3
Divide After

But I'm not too keen on bastardising the meanings of the ini values
I also considered users editing the ini
i.e. its easier to delete lines/sections than to change a value.
Don't want it in a sub menu = delete the line SubMenu=

Hence the seperate section to define the sub menu (which could also benifit from it's own dividebefore/after values)
and the seperate SubMenu= Value.
There is no way to add an icon to the sub menu either without the seperate section :(


I think I understand why you want to do it that way; You need to know the submenu before adding the options?
So run through the file twice, it won't take long
First run check / split items into options and submenus etc
sort the first level items
Second run add whatever is left over. (sub menu items)
sort the second level
third run ....

Your change would look something like this for sub sub menus
DisplayName=Favorites/DEISync Menu/Export Complete DataBase

PS Thinking a little more about it I might even consider creating a custom table for the ini data if I was doing it :)
ID, Level, Section, Filename, Procname, DisplayName, Description, ScriptType, Icon, SubMenu, DividerBefore, DividerAfter
Then just loop a select statement increasing the level each time until you get no more rows; SELECT * FROM RCFS WHERE level = 0 order by DisplayName

Of course you would still have to go through the ini a few times to work out the levels but you wouldn't have to maintian a heap of StringLists.

teapot
Posts: 84
Joined: Fri Jan 18, 2008 9:02 am
Location: WA, USA

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by teapot » Sat Sep 06, 2008 10:27 pm

I'm getting an error when trying to install RightClickForScripts151.mmip that I downloaded this morning. The error message is "Invalid Product Installation Package". I have MM 3.0.4.1185 Gold and ran the install as an Administrator. Can I get help with this issue in this discussion or do I need to post in another area ?

Thanks to you and all the others that write scripts for MM. MM is already great, but with the addition of all the user written scripts it really rocks !


onenonymous
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts -with buttons! (2008-09-07) [MM3]

Post by onenonymous » Sun Sep 07, 2008 11:45 am

Script is updated.

Version 1.6 Update September 7, 2008 - Download the installer
-made lots of code changes based on MoDementia's suggestions (thanks!!!) :D
-streamlined code that processes the scripts.ini file
-added ability to set an icon in the Scripts.ini file, then show it from RCFS. You can set a path to the icon either relative to MM, an absolute path to the file, or a number to use one of MMs built in icons, e.g. any of these will work when included in Scripts.ini (see previous discussions in this thread) :

Code: Select all

Icon=Scripts\View Manager\Icons\table_go.ico
Icon=C:\Windows\mycustom.ico
Icon=22
-For the button/menu maker form, in the Icon edit box, you can now put in <nn> where nn is a number for one of MMs built in icons. For example <22> will use the Monkey icon
-Cleaned up code for placing the separators (I think I got it, but these get tricky so let me know :-? )
-Changed the way it records if one of the separator check-boxes are selected to account for a bug noted earlier with non-English implementations (http://www.mediamonkey.com/forum/viewto ... 50#p165371)
-Added "Clear All" button to the button/menu maker form
-Added button to the button/menu maker form for the first row to clear it also
-Added a new menu item to Refresh Menus. This will delete all the RCFS menus/buttons, then re-build everything, same as if MM was re-started. Because of this, the positions of RCFS menus/buttons relative to other menu items may change. When you restart, they're back where they belong. I'll look into enhancing this for future revisions.
-A few other enhancements to the code to hopefully run more efficiently

I haven't added sub-menu capability to scripts.ini or separators as recently discussed. Those will have to wait for another revision.

Finally - I could easily add in the Right Click For Reports into this script, so rather than having 2 separate scripts, one will do it all. You'd still have the separate RCFS & RCFR sub-menus. You'd also have just one form for adding the buttons and menus for both scripts and reports. What do you all think? Keep em separate or roll them together?

Enjoy! ~One

Eyal
Posts: 3110
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Re: Right Click for Scripts -with buttons! (2008-08-30) [MM3]

Post by Eyal » Sun Sep 07, 2008 1:03 pm

Thanks a lot for all the improvements.
onenonymous wrote:Keep em separate or roll them together?
Keep them separate please. A report is a report, a script is a script.
Eyal
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].

Post Reply