Up | CameraError | ImageComplete | LoadTools | SaveTools | ToolApply | ToolVariantChange | DataInputApply | Query Events | UpdateResultPanel | UpdateIndicatorPanel | ContextChange | Mouse Events | Timer | LogMsg

 

  

 
Mouse Events

The MouseDown and MouseUp events are called when you click within an image.

Syntax:

MouseDown(Image,Shift,X,Y)
MouseUp(Image,Shift,X,Y)

Parameters:

  • Image - string - name of the image you clicked in
  • Shift - integer - bit state of mouse buttons and keyboard shift, ctrl and alt buttons
    • Bit 0 - Shift key up/down
    • Bit 1 - Alt key up/down
    • Bit 2 - Ctrl key up/down
    • Bit 3 - Left mouse button up/down
    • Bit 4 - Right mouse key up/down
    • Bit 5 - Middle mouse key up/down
    • Bit 6 - Double mouse click
  • X, Y - float - image position in pixel coordinates

By returning 1, the default mouse action will not be handled by Scorpion.

Example 1:  Drawmarker at mouse position

def Handle_System_MouseDown(Image,Shift,X,Y):
#
# Image = VT_BSTR
# Shift = VI_I4
# X = VT_R4
# Y = VT_R4
#
# Return 1 if handled by script
# Return 0 if default handling
#
  global trainingMode
  if trainingMode and Shift==12:    #Ctrl+LButton
    if X>200 and X<250:
     if Y>300 and Y<355:
      DrawAt(Image)
      DrawMarker('',X,Y,'red',5,5)
      return 1  #ignore default processing
  return 0      #do default processing

Example 2: Trigger inspection on AltGr mouseclick

def Handle_System_MouseDown(Image,Shift,X,Y):

  print 'Shift',Shift
  if Shift==14 and GetValue('System.Running')==0:
    print 'X,Y',X,Y

    x,y = PixToRef( 'RobotCoordinates',X,Y)
    SetConfigValue('RoughPositionFromRobot.InitialValue.X',x)
    SetConfigValue('RoughPositionFromRobot.InitialValue.Y',y)
    ExecuteCmd('InspectExecute','')

  return 0

Example 3: Disable image zooming

def Handle_System_MouseDown(Image,Shift,X,Y):
  return 1

def Handle_System_MouseUp(Image,Shift,X,Y):
  return 1

 


Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.