Doc & Tips: Mouse Commands

 

 

Starting from PsyScope X Build 57, we expanded the possibility to use the mouse in experiments, introducing several new actions: MousePos, MouseSwitch, and MouseTo.

-- MousePos allows you to load into a variable of type Point the current position of the mouse with the Action MousePos (available from the graphical interface under the "Actions" list).Thus, if Mousevar is a variable of type Point, that is, it is defined as:

Mousevar::
  Type: Point:
  Update: TRUE
  v: 280
  h: 480

then the following Condition-Action pair

EventActions: Conditions[ End[] ] => Actions[ MousePos[ Mousevar ]

will assign the mouse position to Mousevar when the event containing the Condition-Action pair ends.

You can then recall the single X and Y values of the mouse positions by assigning them to variables of type Integer. Thus, if TheX and TheY are such variables, a Set action such as:

Set[ TheX "Mousevar->h" ] Set[ TheY "Mousevar->v"]

will retrieve the mouse coordinates previously saved in the variable Mousevar. This script shows how you can retrieve successive mouse positions, and even replay them later (the timing is not accurate, though).

-- MouseSwitch.Sometimes it is useful to make the cursor to appear or disappear during the experiment. We addded an action to do this. The action is MouseSwitch

and is available in the graphical interface. It takes parameters 0 and 1. So an an action like

Actions[ MouseSwitch[ 1 ]]

will make the cursor appear even if it was off by default during the execution of the script.

-- MouseTo. Finally, with the action MouseTo, also available from the graphical interface, you can move the cursor to a set position on the screen. MouseTo needs a variable of type Point. So assuming that Mousevar is such variable, this acion:

Actions[ MouseTo[ Mousevar ]]

will make the cursor appear at the position specified by the variable,as you can see in this simple example script.

That's it for mouse commands.