FANDOM


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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.