-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon Hofmann
committed
Sep 19, 2019
0 parents
commit dc8e820
Showing
68 changed files
with
10,427 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!--- Provide a general summary of the issue in the Title above. --> | ||
|
||
## Expected Behavior | ||
<!--- If you're describing a bug, tell us what should happen. --> | ||
<!--- If you're suggesting a change/improvement, tell us how it should work. --> | ||
|
||
## Current Behavior | ||
<!--- If describing a bug, tell us what happens instead of the expected behavior. --> | ||
<!--- If suggesting a change/improvement, explain the difference from current behavior. --> | ||
|
||
## Possible Solution | ||
<!--- Not obligatory, but suggest a fix/reason for the bug, --> | ||
<!--- or ideas how to implement the addition or change. --> | ||
|
||
## Steps to Reproduce (for bugs) | ||
<!--- Please provide an unambiguous set of steps to reproduce this bug. --> | ||
<!--- Include code to reproduce. --> | ||
1. | ||
2. | ||
3. | ||
4. | ||
|
||
## Context | ||
<!--- How has this issue affected you? What are you trying to accomplish? --> | ||
<!--- Providing context helps us come up with a solution that is most useful in the real world. --> | ||
|
||
## Your Environment | ||
<!--- Include as many relevant details about the environment you experienced the bug in. --> | ||
* RobotJS version: | ||
* Node.js version: | ||
* npm version: | ||
* Operating System: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build/ | ||
node_modules/ | ||
prebuilds/ | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "10" | ||
- "11" | ||
- "12" | ||
|
||
os: | ||
- linux | ||
- osx | ||
|
||
cache: | ||
directories: | ||
- node_modules | ||
|
||
git: | ||
depth: 5 | ||
|
||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- libx11-dev | ||
- zlib1g-dev | ||
- libpng12-dev | ||
- libxtst-dev | ||
- g++-4.8 | ||
- gcc-4.8 | ||
|
||
before_install: | ||
# print versions | ||
- node --version | ||
- npm --version | ||
|
||
# use g++-4.8 on Linux | ||
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi | ||
|
||
# before_script: | ||
# Start xvfb | ||
# - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export DISPLAY=:99.0; fi | ||
# - if [[ $TRAVIS_OS_NAME == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi | ||
|
||
install: | ||
- npm install | ||
|
||
script: | ||
- npm run build:release | ||
|
||
# after_success: | ||
# - if [[ $TRAVIS_TAG != "" ]]; then npm run prebuild -- -u $GITHUB_TOKEN; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
project(libnut) | ||
|
||
# Source | ||
set(SOURCE_FILES "src/libnut.cc" "src/deadbeef_rand.c" "src/mouse.c" "src/keypress.c" "src/keycode.c" "src/screen.c" "src/screengrab.c" "src/snprintf.c" "src/MMBitmap.c") | ||
if (LINUX) | ||
set(SOURCE_FILES "${SOURCE_FILES}" "src/xdisplay.c") | ||
endif() | ||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) | ||
|
||
# Includes | ||
include_directories("${CMAKE_SOURCE_DIR}/src/include") | ||
|
||
set(LIBS "") | ||
set(INCLUDES "") | ||
|
||
# External libs | ||
if (APPLE) | ||
message(STATUS "macOS build") | ||
set(LIBS "${LIBS}" "-framework ApplicationServices") | ||
set(LIBS "${LIBS}" "-framework Carbon") | ||
set(LIBS "${LIBS}" "-framework CoreFoundation") | ||
set(LIBS "${LIBS}" "-framework OpenGL") | ||
elseif (WIN32) | ||
message(STATUS "Windows build") | ||
elseif (LINUX) | ||
message(STATUS "Linux build") | ||
set(LIBS "${LIBS}" "-lpng") | ||
set(LIBS "${LIBS}" "-lz") | ||
set(LIBS "${LIBS}" "-lX11") | ||
set(LIBS "${LIBS}" "-lXtst") | ||
endif() | ||
|
||
set(CMAKE_C_FLAGS "-Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization") | ||
set(CMAKE_C_FLAGS_RELEASE "-O3") | ||
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
message(STATUS "No MSVC compiler in use, adding compile flags -Wextra") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") | ||
endif() | ||
|
||
# add_compile_definitions(NAPI_CPP_EXCEPTIONS) | ||
|
||
# cmake-js | ||
set(INCLUDES ${INCLUDES} ${CMAKE_JS_INC}) | ||
set(LIBS ${LIBS} ${CMAKE_JS_LIB}) | ||
message(STATUS "Libs: ${LIBS}") | ||
|
||
# N-API | ||
# target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/node_modules/node-addon-api") | ||
|
||
# Change suffix to *.node | ||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") | ||
|
||
# BUILD | ||
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDES}) | ||
target_link_libraries(${PROJECT_NAME} ${LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## Disclaimer | ||
|
||
This project if based on [octaImage/robotjs](https://github.com/octalmage/robotjs) and is used internally at [nut-tree/nut.js](https://github.com/nut-tree/nut.js). | ||
|
||
## Building | ||
|
||
Please ensure you have the required dependencies before installing: | ||
|
||
* Windows | ||
* windows-build-tools npm package (`npm install --global --production windows-build-tools` from an elevated PowerShell or CMD.exe) | ||
* Mac | ||
* Xcode Command Line Tools. | ||
* Linux | ||
* cmake | ||
* A C/C++ compiler like GCC. | ||
* libxtst-dev and libpng++-dev (`sudo apt-get install libxtst-dev libpng++-dev`). | ||
|
||
### Release build | ||
|
||
``` | ||
npm install | ||
npm run build:release | ||
``` | ||
|
||
Installation and build on Windows | ||
|
||
``` | ||
npm install | ||
npm run build:release:win | ||
``` | ||
|
||
### Debug build | ||
|
||
``` | ||
npm install | ||
npm run build:debug | ||
``` | ||
|
||
Installation and build on Windows | ||
|
||
``` | ||
npm install | ||
npm run build:debug:win | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# http://www.appveyor.com/docs/appveyor-yml | ||
|
||
environment: | ||
matrix: | ||
# node.js | ||
- nodejs_version: 10 | ||
- nodejs_version: 11 | ||
- nodejs_version: 12 | ||
|
||
cache: | ||
- node_modules | ||
|
||
clone_depth: 5 | ||
|
||
platform: | ||
- x86 | ||
- x64 | ||
|
||
# Install scripts. (runs after repo cloning) | ||
install: | ||
- ps: Install-Product node $env:nodejs_version $env:platform | ||
- npm -g install npm | ||
- set PATH=%APPDATA%\npm;%PATH% | ||
# Typical npm stuff. | ||
- npm install | ||
- npm run build:release:win | ||
|
||
# test_script: | ||
# Output useful info for debugging. | ||
# - node --version | ||
# - npm --version | ||
# run tests | ||
# - npm test | ||
|
||
on_success: | ||
- IF defined APPVEYOR_REPO_TAG_NAME npm run prebuild -- -u %GITHUB_TOKEN% | ||
|
||
build: off | ||
version: "{build}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export interface Bitmap { | ||
width: number; | ||
height: number; | ||
image: any; | ||
byteWidth: number; | ||
bitsPerPixel: number; | ||
bytesPerPixel: number; | ||
colorAt(x: number, y: number): string; | ||
} | ||
|
||
export interface Screen { | ||
capture(x?: number, y?: number, width?: number, height?: number): Bitmap; | ||
} | ||
|
||
export function setKeyboardDelay(ms: number): void; | ||
export function keyTap(key: string, modifier?: string | string[]): void; | ||
export function keyToggle( | ||
key: string, | ||
down: string, | ||
modifier?: string | string[] | ||
): void; | ||
export function typeString(string: string): void; | ||
export function typeStringDelayed(string: string, cpm: number): void; | ||
export function setMouseDelay(delay: number): void; | ||
export function moveMouse(x: number, y: number): void; | ||
export function moveMouseSmooth(x: number, y: number): void; | ||
export function mouseClick(button?: string, double?: boolean): void; | ||
export function mouseToggle(down?: string, button?: string): void; | ||
export function dragMouse(x: number, y: number): void; | ||
export function scrollMouse(x: number, y: number): void; | ||
export function getMousePos(): { x: number; y: number }; | ||
export function getPixelColor(x: number, y: number): string; | ||
export function getScreenSize(): { width: number; height: number }; | ||
|
||
export const screen: Screen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var libnut = require("bindings")("libnut.node"); | ||
|
||
module.exports = libnut; | ||
|
||
module.exports.screen = {}; | ||
|
||
function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image) { | ||
this.width = width; | ||
this.height = height; | ||
this.byteWidth = byteWidth; | ||
this.bitsPerPixel = bitsPerPixel; | ||
this.bytesPerPixel = bytesPerPixel; | ||
this.image = image; | ||
|
||
this.colorAt = function(x, y) { | ||
return libnut.getColor(this, x, y); | ||
}; | ||
} | ||
|
||
module.exports.screen.capture = function(x, y, width, height) { | ||
//If coords have been passed, use them. | ||
if ( | ||
typeof x !== "undefined" && | ||
typeof y !== "undefined" && | ||
typeof width !== "undefined" && | ||
typeof height !== "undefined" | ||
) { | ||
b = libnut.captureScreen(x, y, width, height); | ||
} else { | ||
b = libnut.captureScreen(); | ||
} | ||
|
||
return new bitmap( | ||
b.width, | ||
b.height, | ||
b.byteWidth, | ||
b.bitsPerPixel, | ||
b.bytesPerPixel, | ||
b.image | ||
); | ||
}; |
Oops, something went wrong.