Mouse Move

 

The most common use of the mouse in macros is to move the cursor to a particular spot and click on a button or menu command. The first step in this process is to click on the Mouse Move command.

 

For the mouse functions to be accurate, use the Mouse Locator to determine the exact coordinates of the button or menu command on the window or screen.

 

 

Script Editor > Expand Mouse Category > Mouse Move 

 

 

Select the location to where you would like to move the mouse

First select from the drop down menu the frame of reference for the mouse movement. The five options are discussed in detail below.

 

To the Text Cursor Position

This option instructs the macro to move the mouse to the location of the text cursor. The text cursor is the flashing bar that appears on screens where text input is to be made. This can be particularly useful for applications that do not support the SHIFT and Arrow Keys for highlighting text for clipboard copying.

 

To copy text to the clipboard with the mouse, first use the keyboard to tab to the desired field and the arrow keys to position the cursor. Use the Text Cursor Position function to move the mouse to the same spot as the text cursor. A Mouse Left Click Down command and a Mouse Move Relative to Position command followed by a Mouse Left Click Up highlights text for a clipboard capture.

 

Note: This function does not work on programs that create and use their own text cursor. Programs with their own text cursor do not use the built in Windows Text Cursor functions. Ironically, MS Word appears to fall into this category.

 

Relative to Screen

This option instructs the macro to move the mouse cursor relative to its position on the computer screen. Use the "Screen Coordinates" numbers from the Mouse Locator with this option.

 

Relative to Window

This option instructs the macro to move the mouse cursor relative to its position within the window that is active. Use the "Active Window" numbers from the Mouse Locator with this option.

 

Relative to Last Position

This option instructs the macro to move the mouse cursor relative to the last position of the cursor. In this case do not input new coordinates, just the number of pixels for the mouse to move.

 

For example assume that the mouse position relative to the screen is X = 100, Y = 200. This means the cursor is 100 pixels from the left edge of the screen and 200 pixels from the top edge of the screen. If we were to plug in X = 20, Y = 50, then the mouse would move to an X coordinate of 120 and a Y coordinate of 250. Or, if we plugged in X = -20, and Y = -50 then the mouse would move to an X coordinate of 80 and a Y coordinate of 150 based on our original mouse position.

 

Use the Mouse Locator and some simple math to determine how many pixels are needed to move. Start with the first position and jot down the X and Y coordinates. Move the cursor to the new location and subtract the difference. If the starting position is X = 400 and Y= 450 and the new position is X = 500 and Y = 500, then plug in the values of X = 100 and Y = 50.

 

Select coordinates by either entering the coordinates directly or assigning the coordinate value to a variable. An example of using variables might be to save the original mouse location into variables and then move the mouse back to the original location when finished processing the macro.

 

Relative to Control

This option assumes using a previously defined Window Control saved to a variable. Enter the name of the control variable or select it from the variable list and then select the coordinates. The coordinates 0, 0 refer to the top left corner of the control. Change the coordinates to move a number of pixels to the right and down from the top.

 

Assume that 10 is assigned as the X coordinate and 15 is the Y coordinate. In this case the mouse cursor would point10 pixels to the right of the left edge of the control and 15 pixels down from the top.

 

Note 1: When using the Relative to Screen or Relative to Window options, open the Mouse Locator and position the mouse to the desired location. Then press the Ctrl Key and Space Bar to insert the coordinates into the X and Y fields.

 

Note 2: With each of the above selections, except for the Text Cursor Position, optionally use Integer variables for the coordinate values.

 

 

Launch Mouse Locator       

Clicking on the Launch Mouse Locator button activates the Mouse Locator utility. If this window pops up in an area of the screen that covers important data, click on the window, hold the left mouse button down on the window title bar and drag to another part of the screen.

 

 

Screen Position

The set of numbers directly under Screen Position lists the position of the mouse relative to the computer screen. As the mouse is moved, the numbers on the Mouse Locator window change in relation to the mouse cursor position. The number to the left is the X coordinate, or how many pixels from the left edge of the screen. The number on the right is the Y coordinate, or how many pixels the mouse is positioned below the top edge of the screen.

 

Active Window

The set of numbers directly under Active Window lists the position of the mouse relative to the active window or the window that has the focus. The Mouse Locator window takes focus when it is first launched. Give focus back to the window and the Mouse Locator window remains on top in order to read the coordinates of the window.

 

As the mouse moves, notice the numbers changing in relation to the mouse position. The number to the left is the X coordinate, or how many pixels the mouse is positioned from the left edge of the active window. The number on the right is the Y coordinate, or how many pixels the mouse is positioned from the top of the active window.

 

Pixel Color

This option displays the color of the pixel underneath the mouse pointer. Windows assigns a numeric value to each color, normally from 6 to 8 digits in length. The left side is the decimal value.  The right side displays the hexadecimal value in BGR format. The bottom row displays the pixel color in separate values for Red, Green and Blue. The pixel color is used with the Get Pixel Color command and is not needed for the Mouse Move command.

 

Click the X in the upper right corner to close the Mouse Locator window.