DO 11 Script escape variable containing a URL

I'm trying to make a simple script that launches Internet Download Manager and downloads the link. So far the script launches IDM, but does not download the link.

Function OnClick(ByRef ClickData)
 Dim test
 test = "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_2160p_60fps_normal.mp4"

	ClickData.Func.Command.RunCommand " ""E:\Program Files (x86)\Internet Download Manager\IDMan.exe "" /n /p j:\ /d & test "
	 
        logMsg(test)
End Function

Sub logMsg(ByRef message)

   DOpus.OutputString(message)

End Sub


You need to put test outside of the quotes since it's a variable.

Thanks, it works now.

I made a Dopus dialog popup when I don't have text in the clipboard. When I run my script, it doesn't launch IDM anymore or output any logs/errors. I restarted Dopus and tried clicking my idm button/run the script in the cli with no output.

@script vbscript
option explicit
 
Function OnClick(ByRef ClickData)
        Dim objClipFiles
        Dim strClip
        Dim strClipArray
        Dim strPath
        Dim x
 
        If DOpus.GetClipFormat() = "text" Then
 
                strClip = DOpus.GetClip("text")
                strClipArray = Split(strClip, Chr(13) & Chr(10))
 
        End If
       
        Set objClipFiles = DOpus.GetClip("files")
        strClipArray = Empty
       
        For each x in objClipFiles
       
        If IsEmpty(strClipArray) Then
       
                ReDim strClipArray(0)
 
        Else
 
                ReDim Preserve strClipArray(UBound(strClipArray)+1)
 
        End If
 
        Next
 
        If
        ClickData.Func.Dlg.Request "Clipboard does not contain text.", "OK"
        End if
Exit Function
       
 
        For each x in strClipArray
 
                If strClip <> "" Then
 
        ClickData.Func.Command.RunCommand " ""E:\Program Files (x86)\Internet Download Manager\IDMan.exe "" /n /p j:\ /d "& strClip
                        logMsg(strClip)
        Next
 
        End if
End Function
 
Sub logMsg(ByRef message)
 
   DOpus.OutputString(message)
 
End Sub


The attached image cuts off
line 59 has End Sub

When I have no text I get a dialog popup, but when I have any link in the clipboard I nothing happens.

If I have no text in the clipboard, I get a dialog popup. If I have any link in the clipboard nothing happens. ***

Aren't you clobbering the script before it executes any command with that conspicuously unindented "Exit Function" call :slight_smile: ?

Also, use more logging in amongst all the new code you added to see if things are working as you expected and try putting the entire command into another string and log that instead of just logging the strClip var... this way you'll see what the full command is that you're asking Opus to execute. Modify your script until you get a command line that you can execute properly outside of Opus (Start -> Run, etc).

Besides that, I'm not sure what you're accomplishing with the 'DOpus.GetClip("files")' stuff... or that If ClickData.Func.Dlg.Request thing...

You have a spurious Exit Function on line 40 that's aborting the script early.

Thanks for the help Jon and Steje. I made the script work finally :smiley:

When I use If (Script.config.DEBUG) Then DOpus.OutputString(message) in the subroutine at the bottom
I get an error message "Variable is undefined: 'Script' (0x800a01f4)."

http://pastebin.com/y8w9nJWJ


You're mixing up script add-ins and script functions.

[ul][li]Script Functions go directly into buttons/hotkeys, and have a single defined method - OnClick.[/li]
[li]Script Add-ins go into the /dopusdata/Script AddIns folder and have an OnInit and other methods.[/li][/ul]

Only Script Add-ins have access to the global Script object.

Oh that makes sense. Thanks!