https://github.com/wiggin77/robotjs-externs
Haxe externs for RobotJS. (http://robotjs.io/)
https://github.com/wiggin77/robotjs-externs
haxe robotjs
Last synced: 4 months ago
JSON representation
Haxe externs for RobotJS. (http://robotjs.io/)
- Host: GitHub
- URL: https://github.com/wiggin77/robotjs-externs
- Owner: wiggin77
- Created: 2017-02-18T17:38:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-03T22:07:37.000Z (over 8 years ago)
- Last Synced: 2025-12-19T20:27:16.808Z (7 months ago)
- Topics: haxe, robotjs
- Language: Haxe
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/wiggin77/robotjs-externs)
=========
Haxe externs for [RobotJS](http://robotjs.io/). RobotJS is a desktop automation library for Node.js.
Inject keystrokes and mouse moves into a Node.js application. Also capture mouse position and screen pixels.
## Samples
A simple test app for Node.js is [here](./test/simple/README.md).
A sample app for VSCode/Electron is [here](./test/vscode-electron/README.md).
## Installation
Install `robot-externs` lib for Haxe:
```
haxelib git robotjs-externs https://github.com/wiggin77/robotjs-externs.git
```
Install RobotJS module. From the directory of the project for which you want to add RobotJS support (i.e. directory containing `package.json`):
```
npm install robotjs
```
This will create a `node_modules` directory within your project directory.
## Building RobotJS
`npm` will install prebuilt binaries for Windows, Mac, and Linux. If you need to build it yourself, see [here](http://robotjs.io/docs/building).
To build for Electron see [here](http://robotjs.io/docs/electron).
## Examples
Examples modified for Haxe from [http://robotjs.io/docs/examples](http://robotjs.io/docs/examples).
### Mouse
```haxe
import js.robotjs.Robot;
class Test {
public static function test() {
// Speed up the mouse.
Robot.setMouseDelay(2);
var twoPI = Math.PI * 2.0;
var screenSize = Robot.getScreenSize();
var height = (screenSize.height / 2) - 10;
var width = screenSize.width;
for (x in 0...width)
{
var y = Std.int(height * Math.sin((twoPI * x) / width) + height);
Robot.moveMouse(x, y);
}
}
}
```
### Keyboard
```haxe
import js.robotjs.Robot;
import js.robotjs.RobotHelper;
class Test {
public static function test() {
// Type "Hello World".
Robot.typeString("Hello World");
// Press enter.
Robot.keyTap("enter");
// Use helper for auto-shift modifier.
RobotHelper.typeString("_Mixed shift and non-shift!");
}
}
```
### Screen
```haxe
import js.robotjs.Robot;
class Test {
public static function test() {
// Get mouse position.
var mouse = Robot.getMousePos();
// Get pixel color in hex format.
var hex = Robot.getPixelColor(mouse.x, mouse.y);
trace("#" + hex + " at x:" + mouse.x + " y:" + mouse.y);
}
}
```