Guidance
指路人
g.yi.org
Software / Reginald / Examples / mousesim.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* 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)
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2017-6-22  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:55