Macros to Click&Drag an object X pixels

User avatar
Xcessity
Site Admin
Posts: 217
Joined: Sat May 16, 2015 2:23 pm
Location: Graz
Contact:

Macros to Click&Drag an object X pixels

Postby Xcessity » Fri Aug 07, 2015 10:29 am

Hi,

I got a request where someone wants to move an object just a small amount of pixels in a drawing application using IRIS. To do that you usually need to click & drag an object a fixed amount of pixels.

I have created a set of macros where you first can select the amount of pixels that you want to move the object (1px, 10px, 50px). Once the desired distance is set you can choose the direction you want to move (left, up, right, down).

So in total we need 7 interactors (3x distances + 4x directions).


I created the following interactors:
Label: 1px, Action type: Macro, Macro to execute: "Set1px"
Label: 10px, Action type: Macro, Macro to execute: "Set10px"
Label: 50px, Action type: Macro, Macro to execute: "Set50px"

Label: UP, Action type: Macro, Macro to execute: "ClickAndDragUp"
Label: DOWN, Action type: Macro, Macro to execute: "ClickAndDragDown"
Label: LEFT, Action type: Macro, Macro to execute: "ClickAndDragLeft"
Label: RIGHT, Action type: Macro, Macro to execute: "ClickAndDragRight"


When you create the first interactor go to "Edit"->"Action"->"Action type: Macro"->"Edit"
A textfile will be opened where you can copy and past the macros below. Make sure that the macros are pasted between the <XY_MACROS></XY_MACROS> tags! (eg. when pasting the macros at the end of the document, make sure to add them to the second last line! Last line must be: "</XY_MACROS>")

Code: Select all

<MACRO id="Set1px">
  <MAIN>
    <VARIABLE id="move_distance_px" function="SET" value="1"/>
  </MAIN>
</
MACRO>

<
MACRO id="Set10px">
  <MAIN>
    <VARIABLE id="move_distance_px" function="SET" value="10"/>
  </MAIN>
</
MACRO>

<
MACRO id="Set50px">
  <MAIN>
    <VARIABLE id="move_distance_px" function="SET" value="50"/>
  </MAIN>
</
MACRO>
  
  
<MACRO id="ClickAndDragLeft">
  <START>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="PRESS"/>
  </START>
  <MAIN>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="1"/>
      <MOUSEMOVEINPUT x="-1" y="0" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="10"/>
      <MOUSEMOVEINPUT x="-10" y="0" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="50"/>
      <MOUSEMOVEINPUT x="-50" y="0" behaviour="RELATIVE"/>
    </CONDITION>
  </MAIN>
  <END>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="RELEASE"/>
  </END>
</
MACRO>

<
MACRO id="ClickAndDragRight">
  <START>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="PRESS"/>
  </START>
  <MAIN>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="1"/>
      <MOUSEMOVEINPUT x="1" y="0" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="10"/>
      <MOUSEMOVEINPUT x="10" y="0" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="50"/>
      <MOUSEMOVEINPUT x="50" y="0" behaviour="RELATIVE"/>
    </CONDITION>
  </MAIN>
  <END>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="RELEASE"/>
  </END>
</
MACRO>

<
MACRO id="ClickAndDragUp">
  <START>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="PRESS"/>
  </START>
  <MAIN>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="1"/>
      <MOUSEMOVEINPUT x="0" y="-1" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="10"/>
      <MOUSEMOVEINPUT x="0" y="-10" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="50"/>
      <MOUSEMOVEINPUT x="0" y="-50" behaviour="RELATIVE"/>
    </CONDITION>
  </MAIN>
  <END>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="RELEASE"/>
  </END>
</
MACRO>

<
MACRO id="ClickAndDragDown">
  <START>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="PRESS"/>
  </START>
  <MAIN>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="1"/>
      <MOUSEMOVEINPUT x="0" y="1" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="10"/>
      <MOUSEMOVEINPUT x="0" y="10" behaviour="RELATIVE"/>
    </CONDITION>
    <CONDITION>
      <VARIABLECONDITION id="move_distance_px" condition="EQUAL" value="50"/>
      <MOUSEMOVEINPUT x="0" y="50" behaviour="RELATIVE"/>
    </CONDITION>
  </MAIN>
  <END>
    <MOUSEBUTTONINPUT button="LEFT" behaviour="RELEASE"/>
  </END>
</
MACRO>
 

Return to “Macros”