Here's a VBScript to do something close. It finds the script/batch file from the last User Tool run and launches whatever Edit action associated with that file. Copy the code to NotePad and save it as EditLUT.vbsOption Explicit ' Edit Last NWC2 User Tool Run
' Standalone script, not a User Tool
' by Rick G. tested on Win98, NWC2 Beta 2.19
Const exts = ".php|.vbs|.js|.py|.cmd|.bat"
Const NWC2RK = "HKCU\Software\NoteWorthy Software\NoteWorthy Composer 2\"
Dim wso: Set wso = CreateObject("WScript.Shell")
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim sho: Set sho = CreateObject("Shell.Application")
Dim ext, delimiter, lut, s
lut = wso.RegRead(NWC2RK & "Options\LastToolRun")
s = fso.BuildPath(NWC2Folder("Config"), "nwc2UserTools.ini") ' filename
s = fso.OpenTextFile(s).ReadAll ' file contents
s = Filter(Split(s, vbCr), vbLf & lut & "=")(0) ' pertinent line from file
s = Split(s, "=")(1) ' &Command:
For Each ext In Split(exts & "|", "|")
If InStr(1, s, ext, 1) Then Exit For
Next
If ext = "" Then WScript.Quit ' no match
If Asc(s) = 39 Then s = Mid(s, 2, Len(s) - 2) ' strip single quotes
delimiter = Mid(s & " ", InStr(1, s, ext, 1) + Len(ext), 1) ' space|quote
s = Filter(Split(s, delimiter), ext, vbTrue, 1)(0) ' relative path
wso.CurrentDirectory = NWC2Folder("root")
s = fso.GetAbsolutePathName(s)
sho.Namespace(Left(s, 3)).ParseName(Mid(s, 4)).InvokeVerb("&Edit")
Function NWC2Folder(sKey)
Select Case sKey
Case "Songs": NWC2Folder = wso.SpecialFolders("MyDocuments")
Case "InstrumentTrees": NWC2Folder = "itrees"
Case "AutoSave", "Config", "Templates": NWC2Folder = sKey
Case "PageCopy", "root"
Case Else: Err.Raise 17, "NWC2Folder", sKey ' bad sKey
End Select
On Error Resume Next
NWC2Folder = wso.RegRead(NWC2RK & sKey)
If Err = 0 Or sKey = "Songs" Then Exit Function
NWC2Folder = fso.BuildPath(fso.GetFile( _
wso.RegRead("HKCR\nwcomposer\shell\nwc2\command\") _
).ParentFolder, NWC2Folder)
End Function
The program gets the last User Tool from the registry and scans nwc2UserTools.ini to find the corresponding line. The line is parsed to find the script filename's path which is usually relative to where nwc2.exe is. This name is fully qualified and passed to Windows' ActiveX "Shell.Application" object with instructions to invoke the "&Edit" verb on it.
A function: NWC2Folder is provided which will return the many folders used by NWC2, whether set by the user or left at their default.
This script cannot be set up as a User Tool. If it is, it will just invoke the editor on itself.