User Tools

Site Tools


automating_20mouse_20actions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

automating_20mouse_20actions [2018/03/31 13:19]
127.0.0.1 external edit
automating_20mouse_20actions [2018/04/16 14:28] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Automating mouse actions===== =====Automating mouse actions=====
  
-//by Richard Russell, October 2008//\\ \\  You may on occasion want to automate mouse actions, such as simulating the effect of the user clicking a button or rotating the wheel. One use for such a facility could, for example, be in a training or tutorial situation where you wish to illustrate how to use the mouse to achieve a particular result.\\ \\  Windows provides the means to do that by means of the **SendInput** API (Windows 98 and later only). The following code has the same effect as the user double-clicking the left mouse button:\\ \\ +//by Richard Russell, October 2008//\\ \\  You may on occasion want to automate mouse actions, such as simulating the effect of the user clicking a button or rotating the wheel. One use for such a facility could, for example, be in a training or tutorial situation where you wish to illustrate how to use the mouse to achieve a particular result.\\ \\  Windows provides the means to do that by means of the **SendInput** API (Windows 98 and later only). The following code has the same effect as the user double-clicking the left mouse button: 
 + 
 +<code bb4w>
         _INPUT_MOUSE = 0         _INPUT_MOUSE = 0
         _MOUSEEVENTF_LEFTDOWN = 2         _MOUSEEVENTF_LEFTDOWN = 2
Line 17: Line 19:
         Input.Mouse.dwFlags% = _MOUSEEVENTF_LEFTUP         Input.Mouse.dwFlags% = _MOUSEEVENTF_LEFTUP
         SYS "​SendInput",​ 1, Input{}, DIM(Input{})         SYS "​SendInput",​ 1, Input{}, DIM(Input{})
-Other constants that you may need are as follows:\\ \\ +</​code> ​        
 + 
 +Other constants that you may need are as follows: 
 + 
 +<code bb4w>
         _MOUSEEVENTF_RIGHTDOWN = &8         _MOUSEEVENTF_RIGHTDOWN = &8
         _MOUSEEVENTF_RIGHTUP = &10         _MOUSEEVENTF_RIGHTUP = &10
Line 23: Line 29:
         _MOUSEEVENTF_MIDDLEUP = &40         _MOUSEEVENTF_MIDDLEUP = &40
         _MOUSEEVENTF_WHEEL = &800         _MOUSEEVENTF_WHEEL = &800
-In the case of wheel movements the **mouseData%** member of the structure must be loaded with a positive value for rotations //away from// the user, and a negative value for rotations //towards// the user. A value of 120 corresponds to one '​click':​\\ \\ +</​code>​ 
 + 
 +In the case of wheel movements the **mouseData%** member of the structure must be loaded with a positive value for rotations //away from// the user, and a negative value for rotations //towards// the user. A value of 120 corresponds to one '​click':​ 
 + 
 +<code bb4w>
         _INPUT_MOUSE = 0         _INPUT_MOUSE = 0
         _MOUSEEVENTF_WHEEL = &800         _MOUSEEVENTF_WHEEL = &800
Line 33: Line 43:
         Input.Mouse.mouseData% = 120         Input.Mouse.mouseData% = 120
         SYS "​SendInput",​ 1, Input{}, DIM(Input{})         SYS "​SendInput",​ 1, Input{}, DIM(Input{})
 +</​code>​
 +
 The **SendInput** API provides many other facilities, such as simulating keyboard input (you can use it as an alternative to the method described at [[/​Faking%20keyboard%20input|Faking keyboard input]]). For full details see the relevant [[http://​msdn.microsoft.com/​en-us/​library/​ms646310.aspx|Microsoft documentation]]. The **SendInput** API provides many other facilities, such as simulating keyboard input (you can use it as an alternative to the method described at [[/​Faking%20keyboard%20input|Faking keyboard input]]). For full details see the relevant [[http://​msdn.microsoft.com/​en-us/​library/​ms646310.aspx|Microsoft documentation]].
automating_20mouse_20actions.txt · Last modified: 2018/04/16 14:28 by richardrussell