automating_20mouse_20actions
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| automating_20mouse_20actions [2018/03/31 13:19] – external edit 127.0.0.1 | automating_20mouse_20actions [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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 " | SYS " | ||
| - | Other constants that you may need are as follows:\\ \\ | + | </ |
| + | |||
| + | 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 ' | + | </ |
| + | |||
| + | 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 ' | ||
| + | |||
| + | <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 " | SYS " | ||
| + | </ | ||
| + | |||
| The **SendInput** API provides many other facilities, such as simulating keyboard input (you can use it as an alternative to the method described at [[/ | The **SendInput** API provides many other facilities, such as simulating keyboard input (you can use it as an alternative to the method described at [[/ | ||
automating_20mouse_20actions.1522502346.txt.gz · Last modified: 2024/01/05 00:18 (external edit)