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

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Postby theta_wave » Fri Jun 13, 2008 8:40 pm

Is there any way to reposition the "scripts menu" above "properties" in the context menu?
theta_wave
 
Posts: 258
Joined: Fri Apr 13, 2007 12:54 am

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby sommo » Sat Jun 28, 2008 12:32 pm

I would just like to say a thank you onenonymous, for this addon!
This is one of the reasons why I use MediaMonkey!
It is really helpful and I do use it :)
Keep up the good work & Happy coding!
sommo
 
Posts: 122
Joined: Thu Nov 08, 2007 9:48 am

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby Eyal » Sat Jun 28, 2008 1:33 pm

Can't download it...
I get
"Invalid Quickkey. This error has been forwarded to MediaFire's development team"

when clicking on the link to download.

Thanks
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Eyal
 
Posts: 3054
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby DazB » Sat Jun 28, 2008 8:47 pm

Hi,

Just tested and download works for me.

Daz
DazB
 
Posts: 409
Joined: Mon Jun 11, 2007 4:09 am
Location: Yorkshire, UK

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby MoDementia » Thu Jul 03, 2008 8:43 pm

Hi onenonymous,

I wonder if you would consider adding ScriptType=99 (or a number of your choosing) script entries to your script.
[EDIT]Better logic would be ScriptType<>1,2,3,4 (Except if another official Type is added)

This would allow Auto scripts (not in scripts.ini) to be added to the Right Click for Scripts list without being added to the normal tools --> Scripts List
The other advantage of having a scripts.ini section is that users can assign hotkeys to previously unavailable auto scripts.
See below for an example. (This won't work with the existing version but will work with the new version I am working on)

Code: Select all
[DEISync1]
Filename=Auto\DEISync.vbs
Procname=ExportCompleteDatabase("Export Complete Database")
Order=99
DisplayName=Export Complete Database
Description=Export Complete Database
Language=VBScript
ScriptType=99
MoDementia
 
Posts: 1320
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby onenonymous » Thu Jul 03, 2008 9:25 pm

It's easy enough to do on my end by editing this line:
Code: Select all
If sValue = 0 And fso.FileExists(sdb.ApplicationPath & "Scripts\" & mnuScript(i)) Then

I'll go ahead and make an update and post here tomorrow, but I'd appreciate hearing any feedback on your suggestion from other scripters?
onenonymous
 
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby MoDementia » Thu Jul 03, 2008 9:39 pm

Thanks, I will be adding a Scripts.ini section for all my auto scripts from now on, if only to make hotkey setting available.
Should I start another thread with a poll so we can all decide on a standard ScriptType for Auto Script Entries perhaps?
MoDementia
 
Posts: 1320
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby nynaevelan » Thu Jul 03, 2008 9:41 pm

I am not a scripter, but as a user I would like to see some of the auto-scripts available in RC4S. My favorite mode of navigation is by right-clicking and your script has made many of my installed scripts easier to use but there are a few that I must still go to the menu for, thus this addition would be very helpful. :D

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5558
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby onenonymous » Fri Jul 04, 2008 8:42 am

after sleeping on your request - I think I'll implement your request by testing for 0 or anything greater than 10. This will give you what you wanted, while allowing the developers to still use numbers up to 10 without my script breaking. If/when they do choose to implement something, I can release an update to account for their changes.
updated installer with this change available here
onenonymous
 
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby MoDementia » Fri Jul 04, 2008 11:58 pm

Thanks heaps but...

The script does have "Script.ScriptPath" but the procname already has a parameter so it ends up with
(param) & (o)

Code: Select all
'####################################################################
' Added by C:\PROGRA~1\MEDIAM~2\Scripts\Auto\RightClickForScripts.vbs
Sub RightClickForScripts_ExportCompleteDatabase("Export Complete Database")(o)
    ExportCompleteDatabase("Export Complete Database")
End Sub
'####################################################################


I tried to fix it and managed to get the added lines they way I thought they should but I don't think I fixed the onclick code aswell :(

If you can get it working i believe you will also have to over come the checking pattern code

The script has 5 ini entries with different parameters but if the parameter is removed they will all look like
Code: Select all
Sub RightClickForScripts_ExportCompleteDatabase(o)

and the others won't be added.

[EDIT]
I managed to get it working. Here is the modified version. You will probably prefer a better method than this one before releasing it :)
Code: Select all
Removed. Better version down further
Last edited by MoDementia on Sat Jul 05, 2008 11:50 pm, edited 1 time in total.
MoDementia
 
Posts: 1320
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby onenonymous » Sat Jul 05, 2008 8:32 am

yours is the first instance I've encountered of the Scripts.ini entry passing a parameter with the procedure. I hadn't even thought about that. I'll think about how to parse for the parameter to handle it gracefully - thanks for your suggested fix.

In the meantime, one suggestion - rather than passing a parameter in Scripts.ini, you could use a unique procedure for each of your 5 Scripts.ini entries, then inside your script, make a procedure for each of these with the "master" procedure and the appropriate parameter.

In Scripts.ini:
Code: Select all
[DEISync1]
Filename=Auto\DEISync.vbs
Procname=ExportCompleteDatabase1
Order=99
DisplayName=Export Complete Database
Description=Export Complete Database
Language=VBScript
ScriptType=99

[DEISync2]
Filename=Auto\DEISync.vbs
Procname=ExportCompleteDatabase2
Order=99
DisplayName=Your 2nd displayname
Description=Your 2nd description
Language=VBScript
ScriptType=99

etc...

In your script:
Code: Select all
Sub ExportCompleteDatabase1
        Call ExportCompleteDatabase("Export Complete Database")
End Sub

Sub ExportCompleteDatabase2
        Call ExportCompleteDatabase("Your 2nd parameter")
End Sub

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

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby MoDementia » Sat Jul 05, 2008 9:57 pm

Although script.ini entries can have parameters (both 0 type and > 10 types) the only reason I created them was to compensate for the missing menu object.

It only just dawned on me that your (o) is what I need to be passed because the parameter required is o.Caption :)

So the ini entries should look like this

Code: Select all
[DEISync1]
Filename=Auto\DEISync.vbs
Procname=ExportCompleteDatabase
Order=99
DisplayName=Export Complete Database
Description=Export Complete Database
Language=VBScript
ScriptType=99
[DEISync2]
Filename=Auto\DEISync.vbs
Procname=ExportCompleteDatabase
Order=99
DisplayName=Export Sync Database
Description=Export Sync Database
Language=VBScript
ScriptType=99

and the added script code should be

Code: Select all
Sub RightClickForScripts_ExportCompleteDatabase(o)
    ExportCompleteDatabase(o)
End Sub


This is certainly a more elegant solution for script types > 10, although I dare say you will one day get a type 0 with parameters. :(

I will see if I can knock up another version soon if you don't beat me to it :)
MoDementia
 
Posts: 1320
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby MoDementia » Sat Jul 05, 2008 11:46 pm

Here is a new version that will just pass the menu object to Auto Scripts
Scipts.ini and added code by RC4S examples in the previous post.
Code: Select all
' MediaMonkey Script
' NAME: RightClickForScripts
' AUTHOR: Onenonymous
' VERSION: 1.41
' DATE: Feb 22, 2008
' UPDATE: July 4, 2008
' FORUM URL: http://www.mediamonkey.com/forum/viewtopic.php?t=26383&start=0
'
' This Script places a new sub-menu when you right click on song(s) in the 4 pop-up
' menus (Main Window, Track List, Now Playing & Menu_Pop_Tree)
' as well as a button in the standard toolbar. Logging options are available
' from the menu in the standard toolbar.
' It reads through the Scripts.ini file and loads any Script of type 0 into the menus.
' July 4 update - also checks for script type > 10
' To use, right click on a song, multiple songs or a node and find the new Scripts menu.
' Select one of the scripts from there. This is the same as if you chose the Script from
' the Scripts menu under the Tools menu. Tested with MM3.
'
' NOTES ON USE:
' To work, we must add some code to each of the scripts we want to use
' off of our Right-Click menus. To do this, we first check each script to
' see if we've already added that code. If not, the other script is
' first backed up with a ".bak" extension, then the original script is
' modified to add our code to the end of the script.
'
' INSTALL INSTRUCTIONS:
' Save as RightClickForScripts.vbs in the Scripts\Auto directory or use the mmip installer file

Option Explicit

CONST SCRIPT_NAME = "RightClickForScripts"
Dim sRCFS_LogFile: sRCFS_LogFile = sdb.ApplicationPath & "Scripts\Auto\RightClickForScripts.vbs" & ".log"
Dim mnuScript, mnuProc, mnuCaption, mnuHint, mnuType, boolLogging
Const ForReading = 1, ForWriting = 2, ForAppending = 8
   
Sub OnStartUp()
' ################################################################################
' Uncomment the line below to turn on forced logging. Use for trouble-shooting only.
 ' sdb.IniFile.BoolValue(SCRIPT_NAME, "Logging") = True
' ################################################################################

   On Error Resume Next
   
   Dim sPath, sProc
    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
   boolLogging = iniMM.BoolValue(SCRIPT_NAME, "Logging")
    Dim objRCFS_menu, objRCFS_submenu, i, j, fso, sIconFile
   Set iniMM = Nothing
   
    RCFS_LogMe "OnStartup enter"

    if not ProcessScriptsIni then exit sub
   RCFS_LogMe "OnStartup - reenter from ProcessScriptsIni"
    Call BubbleSort(mnuCaption)
   RCFS_LogMe "OnStartup - reenter from BubbleSort"

    For j = 1 To 5  'create the menus
        Select Case j
        Case 1
            RCFS_LogMe "Loading menu Menu_Pop_NP_MainWindow"
            If sdb.Objects("Menu_Pop_NP_MainWindow_Scripts") Is Nothing Then
                RCFS_LogMe "  Creating Scripts menu"
                Set objRCFS_menu = sdb.UI.AddMenuItemSub(sdb.UI.Menu_Pop_NP_MainWindow, -1, -1)
                sdb.UI.AddMenuItemSep sdb.UI.Menu_Pop_NP_MainWindow, -1, -2
                Set sdb.Objects("Menu_Pop_NP_MainWindow_Scripts") = objRCFS_menu
            Else
                Set objRCFS_menu = sdb.Objects("Menu_Pop_NP_MainWindow_Scripts")
                 RCFS_LogMe "  Scripts menu already available: Menu_Pop_NP_MainWindow_Scripts"
           End If
        Case 2
            RCFS_LogMe "Loading menu Menu_Pop_TrackList"
            If sdb.Objects("Menu_Pop_TrackList_Scripts") Is Nothing Then
                RCFS_LogMe "  Creating Scripts menu"
                sdb.UI.AddMenuItemSep sdb.UI.Menu_Pop_TrackList, -1, -1
                Set objRCFS_menu = sdb.UI.AddMenuItemSub(sdb.UI.Menu_Pop_TrackList, -1, -1)
                Set sdb.Objects("Menu_Pop_TrackList_Scripts") = objRCFS_menu
            Else
                Set objRCFS_menu = sdb.Objects("Menu_Pop_TrackList_Scripts")
                 RCFS_LogMe "  Scripts menu already available: Menu_Pop_TrackList_Scripts"
           End If
        Case 3
            RCFS_LogMe "Loading menu Menu_Pop_NP"
            If sdb.Objects("Menu_Pop_NP_Scripts") Is Nothing Then
                RCFS_LogMe "  Creating Scripts menu"
                sdb.UI.AddMenuItemSep sdb.UI.Menu_Pop_NP, -1, -1
                Set objRCFS_menu = sdb.UI.AddMenuItemSub(sdb.UI.Menu_Pop_NP, -1, -1)
                Set sdb.Objects("Menu_Pop_NP_Scripts") = objRCFS_menu
            Else
                Set objRCFS_menu = sdb.Objects("Menu_Pop_NP_Scripts")
                 RCFS_LogMe "  Scripts menu already available: Menu_Pop_NP_Scripts"
           End If
        Case 4
            RCFS_LogMe "Loading menu Menu_Pop_Tree"
            If sdb.Objects("Menu_Pop_Tree_Scripts") Is Nothing Then
                RCFS_LogMe "  Creating Scripts menu"
                sdb.UI.AddMenuItemSep sdb.UI.Menu_Pop_Tree, -1, -1
                Set objRCFS_menu = sdb.UI.AddMenuItemSub(sdb.UI.Menu_Pop_Tree, -1, -1)
                Set sdb.Objects("Menu_Pop_Tree_Scripts") = objRCFS_menu
            Else
                Set objRCFS_menu = sdb.Objects("Menu_Pop_Tree_Scripts")
                 RCFS_LogMe "  Scripts menu already available: Menu_Pop_Tree_Scripts"
           End If
        Case 5
            RCFS_LogMe "Loading menu Menu_TbStandard"
            If sdb.Objects("Menu_TbStandard_Scripts") Is Nothing Then
                RCFS_LogMe "  Creating Scripts menu"
                Set objRCFS_menu = sdb.UI.AddMenuItemSub(sdb.UI.Menu_TbStandard, -1, -1)
                Set sdb.Objects("Menu_TbStandard_Scripts") = objRCFS_menu
            Else
                Set objRCFS_menu = sdb.Objects("Menu_TbStandard_Scripts")
                 RCFS_LogMe "  Scripts menu already available: Menu_TbStandard_Scripts"
           End If
        End Select
        objRCFS_menu.Caption = "Scripts"
        objRCFS_menu.Hint = "Displays the scripts"

        sIconFile = sdb.ApplicationPath & "Scripts\Auto\RightClickForScripts.ico"
        Set fso = CreateObject("Scripting.FileSystemObject")
        If fso.FileExists(sIconFile) Then
            objRCFS_menu.IconIndex = sdb.RegisterIcon(sIconFile, 0)
         RCFS_LogMe "    Using icon: " & sIconFile
        Else
            objRCFS_menu.IconIndex = 44
          RCFS_LogMe "    Using icon: 44"
        End If
        Set fso = Nothing

        For i = 1 To UBound(mnuCaption)  ' now load each of the Script menus
            Set objRCFS_submenu = sdb.UI.AddMenuItem(objRCFS_menu, 0, 0)
         sPath = sdb.ApplicationPath & "Scripts\" & mnuScript(i)
         sProc = SCRIPT_NAME & "_" & mnuProc(i)
            With objRCFS_submenu
                .Caption = mnuCaption(i)
            .UseScript = sPath
            .OnClickFunc = sProc
               .Hint = mnuHint(i)
            End With
            RCFS_LogMe "    Added item: " & mnuCaption(i)
        Next

        If j = 5 Then   'we're loading the standard toolbar, so add the logging menus
            sdb.UI.AddMenuItemSep objRCFS_menu, -1, -1

            Set objRCFS_submenu = sdb.UI.AddMenuItem(objRCFS_menu, 0, 0)
            Set sdb.Objects("myRCFS_RCFS_LogMenu") = objRCFS_submenu
            With objRCFS_submenu
                .Caption = "Turn Logging On/Off"
                .Checked = boolLogging
                .Hint = "Turns on or off logging for 'Right Click For Scripts'"
            End With
            Script.RegisterEvent objRCFS_submenu, "OnClick", "ToggleLogging"
            RCFS_LogMe "    Added item: Logging"

            Set objRCFS_submenu = sdb.UI.AddMenuItem(objRCFS_menu, 0, 0)
            Set sdb.Objects("myRCFS_ViewRCFS_LogMenu") = objRCFS_submenu
            With objRCFS_submenu
                .Caption = "View Log"
                .Hint = "Views the 'Right Click For Scripts' Log"
            End With
            Script.RegisterEvent objRCFS_submenu, "OnClick", "ViewLog"
            RCFS_LogMe "    Added item: View Log"

            Set objRCFS_submenu = sdb.UI.AddMenuItem(objRCFS_menu, 0, 0)
            Set sdb.Objects("myRCFS_DeleteRCFS_LogMenu") = objRCFS_submenu
            With objRCFS_submenu
                .Caption = "Delete Log"
                .IconIndex = 8
                .Hint = "Deletes the 'Right Click For Scripts' Log"
            End With
            Script.RegisterEvent objRCFS_submenu, "OnClick", "DeleteLog"
            RCFS_LogMe "    Added item: Delete Log"
            Call ToggleRCFS_LogMenus
        End If
    Next
   
    For i = 1 To UBound(mnuCaption)
      FixScript mnuScript(i), mnuProc(i), mnuType(i)
    Next

    Set objRCFS_submenu = Nothing
    Set objRCFS_menu = Nothing
    RCFS_LogMe "OnStartup exit"
End Sub

Function ProcessScriptsIni()
' Reads through Scripts.ini file to gather info on
' all scripts of type 0 (scripts that go into the 'scripts' menu).
    On Error Resume Next
   
   ProcessScriptsIni = True
   Dim i, fso, iniF, iniPathedFileName, iniLine, ch, _
        p, keyName, lcKeyName, sValue
    RCFS_LogMe "ProcessScriptsIni enter"

    Set fso = CreateObject("Scripting.FileSystemObject")
    iniPathedFileName = sdb.ApplicationPath & "Scripts\Scripts.ini"

    If Not(fso.FileExists(iniPathedFileName)) Then
      RCFS_LogMe "Couldn't find: " & iniPathedFileName
      Msgbox "Couldn't find the Scripts.ini file at:" & vbcrlf & iniPathedFileName & _
      vbcrlf & vbcrlf & "Exiting script: " & vbcrlf & Script.ScriptPath, vbCritical + vbOKOnly, Script.ScriptPath
      ProcessScriptsIni = False
      Exit Function
   end if

    Set iniF = fso.OpenTextFile(iniPathedFileName, 1)
    i = 1

    ReDim mnuScript(1)
    ReDim mnuProc(1)
    ReDim mnuCaption(1)
    ReDim mnuHint(1)
    ReDim mnuType(1)
   
    Do While (Not iniF.AtEndOfStream)    ' loop through all lines in file
        iniLine = iniF.ReadLine
        ch = Mid(iniLine, 1, 1)

        If ((ch <> "") And (ch <> " ") And (ch <> ";") And (ch <> "[") And (ch <> "'")) Then
            ' process the line
            RCFS_LogMe "   Processing line: " & iniLine
            p = InStr(iniLine, "=")
            keyName = Mid(iniLine, 1, p - 1)
            lcKeyName = LCase(keyName)
            sValue = Trim(Mid(iniLine, p + 1))

            Select Case lcKeyName
            Case "filename"
                mnuScript(i) = sValue
            Case "procname"
                mnuProc(i) = sValue
            Case "displayname"
                mnuCaption(i) = Replace(sValue, "&", "")
            Case "description"
                mnuHint(i) = sValue
            Case "scripttype"
                mnuType(i) = sValue
                If (sValue = 0 or sValue > 10) And fso.FileExists(sdb.ApplicationPath & "Scripts\" & mnuScript(i)) Then
                    RCFS_LogMe "       Script:  " & mnuScript(i)
                    RCFS_LogMe "       Proc:    " & mnuProc(i)
                    RCFS_LogMe "       Caption: " & mnuCaption(i)
                    RCFS_LogMe "       Hint:    " & mnuHint(i)
                    i = i + 1  ' increment i each type we get a Script type of 0 & Script is found
                    ReDim Preserve mnuScript(i)
                    ReDim Preserve mnuProc(i)
                    ReDim Preserve mnuCaption(i)
                    ReDim Preserve mnuHint(i)
                    ReDim Preserve mnuType(i)
                End If
            End Select
        End If
    Loop

    ReDim Preserve mnuScript(i - 1)
    ReDim Preserve mnuProc(i - 1)
    ReDim Preserve mnuCaption(i - 1)
    ReDim Preserve mnuHint(i - 1)
    ReDim Preserve mnuType(i - 1)
   
    iniF.Close
    Set iniF = Nothing
    Set fso = Nothing
    RCFS_LogMe "ProcessScriptsIni exit"
End Function

Sub BubbleSort(List())
'   Sorts an array using bubble sort algorithm
    On Error Resume Next
    RCFS_LogMe "BubbleSort enter"

    Dim First, Last
    Dim i
    Dim j
    Dim Temp

    First = LBound(List) + 1
    Last = UBound(List)
    For i = First To Last - 1
        For j = i + 1 To Last
            If List(i) > List(j) Then
                Temp = List(j)
                List(j) = List(i)
                List(i) = Temp

                Temp = mnuScript(j)
                mnuScript(j) = mnuScript(i)
                mnuScript(i) = Temp

                Temp = mnuProc(j)
                mnuProc(j) = mnuProc(i)
                mnuProc(i) = Temp

                Temp = mnuHint(j)
                mnuHint(j) = mnuHint(i)
                mnuHint(i) = Temp

                Temp = mnuType(j)
                mnuType(j) = mnuType(i)
                mnuType(i) = Temp

                Temp = ""
            End If
        Next
    Next
    RCFS_LogMe "BubbleSort exit"
End Sub

Sub FixScript(sScript, sProc, sType)
'checks the Script for "Script.ScriptPath",
' if found, that scripts is backed up then modified

   On Error Resume Next
   RCFS_LogMe "FixScript enter: " & sScript

   Dim sScriptPath, objFSO, objFile, sText, sNewText, sPattern

   sScriptPath = sdb.ApplicationPath & "Scripts\" & sScript
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   Set objFile = objFSO.OpenTextFile(sScriptPath, ForReading)
   sText = objFile.ReadAll
   sPattern = SCRIPT_NAME & "_" & sProc & "(o)"

    If InStr(1, sText, sPattern, vbTextCompare) = 0 Then
        ' didn't find it so we need to add code to the script
      ' first make a copy of the file, then append my code to the end of the script
      objFile.Close
      objFSO.CopyFile sScriptPath, sScriptPath & ".bak", True
      RCFS_LogMe "  Backup Script name: " & sScriptPath & ".bak"
      Set objFile = objFSO.OpenTextFile(sScriptPath, ForAppending)
      objFile.WriteLine ""
      objFile.WriteLine "'####################################################################"
      objFile.WriteLine "' Added by " & Script.ScriptPath
      objFile.WriteLine "Sub " & sPattern
    If sType > 10 Then
        objFile.WriteLine "    " & sProc & "(o)"
    Else
        objFile.WriteLine "    " & sProc
    End If
      objFile.WriteLine "End Sub"
      objFile.WriteLine "'####################################################################"
      objFile.Close
      RCFS_LogMe "  Fixing Script: " & sScriptPath
      RCFS_LogMe "     Added: Sub " & sPattern
   Else
      objFile.Close
        RCFS_LogMe "  No fix needed: " & sScriptPath
   
    End If
    Set objFile = Nothing
    Set objFSO = Nothing
    RCFS_LogMe "FixScript exit"
End Sub

Sub RCFS_LogMe(msg)
'by psyXonova'
    On Error Resume Next
    If boolLogging Then    ' set at the beginning of the Script to enable logging
        Dim fso, logf
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set logf = fso.OpenTextFile(sRCFS_LogFile, ForAppending, True)
        logf.WriteLine Now() & ": " & msg
        Set fso = Nothing
        Set logf = Nothing
    End If
End Sub

Sub ToggleLogging(o)
    On Error Resume Next
   RCFS_LogMe "Logging turned off"
    Dim iniMM: Set iniMM = sdb.IniFile
    boolLogging = Not boolLogging
    sdb.Objects("myRCFS_RCFS_LogMenu").Checked = boolLogging
    iniMM.BoolValue(SCRIPT_NAME, "Logging") = boolLogging
   Set iniMM = Nothing
    ToggleRCFS_LogMenus
    RCFS_LogMe "Logging turned on"
End Sub

Sub ViewLog(o)
    On Error Resume Next
    RCFS_LogMe "ViewLog enter"
    Dim WshShell, fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(sRCFS_LogFile) Then
        Set WshShell = CreateObject("WScript.Shell")
        WshShell.Run ("""" & sRCFS_LogFile & """")
        Set WshShell = Nothing
    Else
        MsgBox "The log file does not exist." & vbCrLf & sRCFS_LogFile, vbInformation
    End If
    Set fso = Nothing
    RCFS_LogMe "ViewLog exit"
End Sub

Sub DeleteLog(o)
    On Error Resume Next
    RCFS_LogMe "DeleteLog enter"
    Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(sRCFS_LogFile) Then
        fso.DeleteFile (sRCFS_LogFile)
        RCFS_LogMe "   Deleted file: " & sRCFS_LogFile
    Else
        MsgBox "No log file to delete." & vbCrLf & sRCFS_LogFile, vbInformation
        RCFS_LogMe "   No file to delete"
    End If
    Set fso = Nothing
    ToggleRCFS_LogMenus
    RCFS_LogMe "DeleteLog exit"
End Sub

Sub ToggleRCFS_LogMenus()
    On Error Resume Next
    RCFS_LogMe "ToggleRCFS_LogMenus enter"
   Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(sRCFS_LogFile) Then
        sdb.Objects("myRCFS_ViewRCFS_LogMenu").Enabled = True
        sdb.Objects("myRCFS_DeleteRCFS_LogMenu").Enabled = True
      RCFS_LogMe " Enabled"
   Else
        sdb.Objects("myRCFS_ViewRCFS_LogMenu").Enabled = False
        sdb.Objects("myRCFS_DeleteRCFS_LogMenu").Enabled = False
       RCFS_LogMe " Disabled"
   End If
    Set fso = Nothing
    RCFS_LogMe "ToggleRCFS_LogMenus exit"
End Sub

sub HideMenus()
   on error resume next
   dim mnu
   RCFS_LogMe "Hiding all menus"
   sdb.Objects("Menu_Pop_Tree_Scripts").Visible = False
   sdb.Objects("Menu_Pop_NP_MainWindow_Scripts").Visible = False
   sdb.Objects("Menu_Pop_TrackList_Scripts").Visible = False
   sdb.Objects("Menu_Pop_NP_Scripts").Visible = False
   sdb.Objects("Menu_TbStandard_Scripts").Visible = False
End Sub

sub ShowMenus()
   on error resume next
   RCFS_LogMe "Showing all menus"
   sdb.Objects("Menu_Pop_NP_MainWindow_Scripts").Visible = True
   sdb.Objects("Menu_Pop_TrackList_Scripts").Visible = True
   sdb.Objects("Menu_Pop_NP_Scripts").Visible = True
   sdb.Objects("Menu_Pop_Tree_Scripts").Visible = True
   sdb.Objects("Menu_TbStandard_Scripts").Visible = True
End Sub

Sub RCFS_Install()
    On Error Resume Next
    If sdb.Objects("myRCFS_RCFS_LogMenu") Is Nothing Then
        Call OnStartUp
    Else
        MsgBox "You must restart MM to reload menus.", vbExclamation
    End If
End Sub

Sub RCFS_UnInstall()
    On Error Resume Next
   RCFS_LogMe "Uninstalling script"
    If (Not (sdb.IniFile Is Nothing)) Then
        sdb.IniFile.DeleteSection (SCRIPT_NAME)
    End If
   HideMenus
End Sub
'
'##### END OF Script #######
MoDementia
 
Posts: 1320
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby onenonymous » Sun Jul 06, 2008 9:51 am

While you say this work for your specific requirement - it doesn't seem to be flexible for other situations. I don't think that I should assume that all script types > 10 require a parameter to be passed. I'll work on code to parse the procedure looking for a parameter to pass it in the snippet I add. I'll have to figure out when to pass the "(o)" and when to pass the parameter the original author put into scripts.ini, and when no parameter is needed at all :-? .

In any case, what did you think about the method I suggested yesterday? It would seem to work in all situations and isn't dependent on my script interpreting which procedures need parameters.
onenonymous
 
Posts: 374
Joined: Sat Feb 02, 2008 1:09 pm
Location: Texas

Re: Right Click for Scripts (2008-04-05) [MM3]

Postby MoDementia » Sun Jul 06, 2008 2:18 pm

onenonymous wrote:While you say this work for your specific requirement - it doesn't seem to be flexible for other situations. I don't think that I should assume that all script types > 10 require a parameter to be passed. I'll work on code to parse the procedure looking for a parameter to pass it in the snippet I add. I'll have to figure out when to pass the "(o)" and when to pass the parameter the original author put into scripts.ini, and when no parameter is needed at all :-? .

In any case, what did you think about the method I suggested yesterday? It would seem to work in all situations and isn't dependent on my script interpreting which procedures need parameters.


It is not my specific reqirement; it is a requirement for 99% of auto scripts. I'm not even sure there are other situations.
Let me expalin further.

My original request was to enable Auto scripts to be used in RC4S
At the moment these will be the only script types > 10.
Unless run from an event all auto scripts will be triggered via a menu/toolbar item which requires (o) to be passed.
Any script type can use parameters. These are almost exclusively used with script types < 10. Auto scripts requiring parameters will already have the relevant code included in the original script but are still triggered from a menu/toolbar option and still require (o) to be passed initially.
An Auto script cannot pass (o) and a parameter at the same time.

So..
Script type > 10 requires (o) to be passed (modified script)
Procname contains "(" requires parameters to be passed (regardless of script type) (yet to be coded)

The modified script is flexible in that it now passes the script type to the relevant subroutine.
I do not believe there are any other variations than the 2 above. If sometime in the future there is then...
Other variations on the 2 scenarios we have so far can be triggered using specific script types (sort of why I tried to get an agreement on a specific script type initially)
e.g.
script type 90 requires (o) to be passed
script type 80 requires (o) and parameters to be passed (param1,param2,o)

Given all of the above users should be able to use RC4S for any auto script they have installed immediately by simply adding a scripts.ini section without the need for the auto script to be modified. Then a request to the original author to have the scripts.ini section added as part of their install routine to be added in a future release. It will not prevent users from using RC4S with the script even if it is never rereleased.

I don't think your suggested method is neccessary and could possibly generate a great deal of requests for other scripts to be modified.
MoDementia
 
Posts: 1320
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

PreviousNext

Return to Need Help with Addons?

Who is online

Users browsing this forum: chenglee and 23 guests