/* An example of FUNCDEF'ing various Windows OS functions * to move the mouse and simulate mouse clicks. */ OPTIONS "WINFUNC C_CALL" NUMERIC DIGITS 10 /* ============== FUNCDEF some needed OS functions ============ */ DO /* Register the Windows OS function mouse_event(). It allows us to * simulate a mouse event (ie, move the mouse and simulate a button * click */ FUNCDEF("mouse_event", ", 32u, 32, 32, 32u, 32u", "user32") CATCH FAILURE CONDITION("M") RETURN END /* Calling mouse_event() simulates one mouse event. With one call, you can * move the mouse any distance, as well as simulate a button click. If you * want to move the mouse several times, or do several button clicks, then * you will have to make several calls to mouse_event(). * * The first arg passed is any of the following, added together: * * MOUSE_ABSOLUTE * Specifies that the second and third args contain normalized absolute * coordinates between 0 and 65,535. These coordinates are mapped onto * the display surface where coordinate (0,0) is the upper-left corner * and (65535,65535) is the lower-right corner. * * If you don't specify MOUSE_ABSOLUTE, then the second and third args * contain relative positions (ie, the change in position since the last * mouse position). Positive values mean the mouse moved right (or down), * negative values mean the mouse moved left (or up). * * MOUSE_MOVE * Specifies that you wish the mouse to be moved by the amount you specify * in the second and third args to mouse_event(). If you don't specify this, * then the second and third args can be omitted, and the mouse is not moved. * * MOUSE_WHEEL * Specifies that the mouse wheel button has moved. * * * MOUSE_LEFTDOWN * Specifies that the left button changed to down. * * MOUSE_LEFTUP * Specifies that the left button changed to up. * * MOUSE_RIGHTDOWN * Specifies that the right button changed to down. * * MOUSE_RIGHTUP * Specifies that the right button changed to up. * * MOUSE_MIDDLEDOWN * Specifies that the middle button changed to down. * * MOUSE_MIDDLEUP * Specifies that the middle button changed to up. * * LEFTDOWN, LEFTUP, RIGHTDOWN, RIGHTUP, MIDDLEDOWN, and MIDDLEUP are added in if * you want to indicate changes in status, not ongoing conditions. For example, * if you want to simulate a press down of the LEFT mouse button, add MOUSE_LEFTDOWN * to the first arg you pass. Subsequent calls to mouse_event() will assume that the * button is still down until such time as you call mouse_event() and add MOUSE_LEFTUP. * * The second arg specifies the mouse's absolute position along the x-axis (or its * amount of motion since the last mouse event was generated, depending upon whether * you added MOUSEEVENTF_ABSOLUTE to the first arg). Absolute data is given as the * mouse's actual x-coordinate; relative data is given as the number of mickeys moved. * * The third arg specifies the mouse's absolute position along the y-axis (or its * amount of motion since the last mouse event was generated, depending upon whether * you added MOUSEEVENTF_ABSOLUTE to the first arg). Absolute data is given as the * mouse's actual y-coordinate; relative data is given as the number of mickeys moved. */ MOUSE_ABSOLUTE = 32768 MOUSE_MOVE = 1 MOUSE_WHEEL = 2048 MOUSE_LEFTDOWN = 2 MOUSE_LEFTUP = 4 MOUSE_RIGHTDOWN = 8 MOUSE_RIGHTUP = 16 MOUSE_MIDDLEDOWN = 32 MOUSE_MIDDLEUP = 64 /* Move the mouse to the absolute position of 0, 0. This puts it in the * top left corner of the desktop. Note that we specify MOUSE_MOVE * */ mouse_event(MOUSE_MOVE + MOUSE_ABSOLUTE, 0, 0) /* Delay for a bit. Note: If using a REXX GUI window, you should not use * SLEEP(). Instead set a timer, and when you get a time event, then do the * next step. */ SLEEP(3) /* Move the mouse by a relative position of 100, 50. (ie, Move it * 100 units to the right, and 50 units down). Also simulate a * right button click. This should pop up some menu on something. */ mouse_event(MOUSE_MOVE, 100, 50) /* Delay for a bit */ SLEEP(5) /* Simulate releasing the right button. Note: Since we're not moving * the mouse, we can omit the second and third args */ mouse_event(MOUSE_RIGHTDOWN)