Commit 7121302 1 parent 89f412c commit 7121302 Copy full SHA for 7121302
File tree 1 file changed +15
-9
lines changed
1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -51,21 +51,27 @@ I [plan on](https://github.com/octalmage/robotjs/issues/64) using node-pre-gyp t
51
51
52
52
##### Mouse
53
53
54
- ``` JavaScript
55
- // Get the mouse position, move it, then click.
54
+ ![ ] ( https://cloudup.com/cw5JY2cusx3+ )
56
55
56
+ ``` JavaScript
57
+ // Move the mouse across the screen as a sine wave.
57
58
var robot = require (" robotjs" );
58
59
59
- // Get the mouse position, returns an object with x and y.
60
- var mouse = robot .getMousePos ();
61
- console .log (" Mouse is at x:" + mouse .x + " y:" + mouse .y );
60
+ // Speed up the mouse.
61
+ robot .setMouseDelay (2 );
62
62
63
- // Move the mouse down by 100 pixels.
64
- robot .moveMouse (mouse .x , mouse .y + 100 );
63
+ var twoPI = Math .PI * 2.0 ;
64
+ var screenSize = robot .getScreenSize ();
65
+ var height = (screenSize .height / 2 ) - 10 ;
66
+ var width = screenSize .width ;
65
67
66
- // Left click!
67
- robot .mouseClick ();
68
+ for (var x = 0 ; x < width; x++ )
69
+ {
70
+ y = height * Math .sin ((twoPI * x) / width) + height;
71
+ robot .moveMouse (x, y);
72
+ }
68
73
```
74
+
69
75
##### Keyboard
70
76
71
77
``` JavaScript
You can’t perform that action at this time.
0 commit comments