Scratchpad

If you are new to Scratchpad, and want full access as a Scratchpad editor, create an account!
If you already have an account, log in and have fun!!

READ MORE

Scratchpad
Advertisement

Introduction[]

This presents some example usages of the Shell Object.

Launching Applications[]

This little snipped will launch notepad when the button has clicked the object

' ///
' Note that for these types of actions it's good practice
' to put them in the mouse up even instead of the 
' mouse down event so the user can cancel the action
' by moving the cursor away from the object before
' releasing the mouse button. Also, if the object
' is movable you want to make sure that the user didn't
' intend to move the object.
' ///

Function Object_OnLButtonUp(x, y, Dragged)
   If Not Dragged Then 'Make sure the object wasn't moved
      Dim objShell
      Set objShell = CreateObject("WScript.Shell")
      objShell.Run "notepad.exe"
   End If
End Function

Batch commands[]

Similarly, you can use this method to create a batch execution of applications or commands

Function Object_OnLButtonUp(x, y, Dragged)
   If Not Dragged Then 'Make sure the object wasn't moved
      Dim objShell
      Set objShell = CreateObject("WScript.Shell")
      objShell.Run "notepad.exe"
      objShell.Run "calc.exe"
      objShell.Run "charmap.exe"
   End If
End Function

Comments/Suggestions[]

Instead of wrapping the important code in an If Not Dragged Then ... End If you can use this statement at the top of the function: If Dragged Then Exit Function -rr

Advertisement