Code Monkey home page Code Monkey logo

keyboardsimulator's Introduction

KeyboardSimulator

CRAN

KeyboardSimulator is a package for R language that make users simulate keyboard event, cursor movement and mouse click with simple R function.

This package provide 6 functions which are developed in C++:

  • keybd.press() Simulate keyboard key presses. Multiple keys can be pressed simultaneously by using + as separator.
  • keybd.release() Simulate the release of keyboard keys held by keybd.press.
  • keybd.type_string() Type a string with simulated keyboard input.
  • mouse.click() Simulate left and right button of mouse clicks.
  • mouse.release() Simulate the release of mouse button held by mouse.click.
  • mouse.get_cursor() Get current cursor coordinate of screen.
  • mouse.move() Move cursor to specific coordinate of screen.

The supported keys are listed in keyboard_value.


FAQ

Does KeyboardSimulator support operating systems other than Windows?

No, KeyboardSimulator is built on top of the Windows API and is not compatible with other operating systems.

This package doesn't work on my computer! How can I make it work?

Open a GitHub issue and let us know what version of Windows you are using and what keyboard and mouse hardware you have connected.


Package Setup

install.packages("KeyboardSimulator")
library(KeyboardSimulator)

or

if (!require("devtools")) install.packages("devtools")
devtools::install_github("ChiHangChen/KeyboardSimulator")
library(KeyboardSimulator)

Examples

Simulate keyboard event

  • Press single key
keybd.press("Enter")
  • Press multiple keys with + as seperator
keybd.press("Alt+f4")
  • Hold keys with argument hold=TRUE and use keybd.release to release the held key
keybd.press("Alt", hold = TRUE)
keybd.press('Tab')
keybd.release('Alt')

Simulate mouse event

  • Get current location of cursor
mouse.get_cursor()
# Return the x,y coordinate of screen
[1] 960 540
  • Press mouse button
mouse.click()
mouse.click("right")
  • Move cursor to the center of screen on 1080FHD monitor
mouse.move(960, 540)
  • Move cursor to the center of screen on 1080FHD monitor within 3 seconds
mouse.move(960, 540, duration=3)
  • Drag an item to center of screen
mouse.click(button = "left", hold = TRUE)
mouse.move(960, 540)
mouse.release()

Developers

Dependencies

It is highly recommended that you use the RStudio IDE to develop this package. In addition to an R installation, you'll also need to install Rtools and a TeX distribution. TeX Live is a comprehensive distribution that seems to work well.

Once you have cloned this repository, you'll need to download the build package dependencies. These dependencies are managed with packrat and can be restored by running

if (!require(packrat)) install.packages("packrat")
packrat::on()
packrat::restore()

Documentation

The roxygen2 R package is used to manage KeyboardSimulator's documentation. Do not edit any of the files that have a warning comment at the top about manually editing those files!

You can regenerate package documentation with the RStudio shortcut Ctrl+Shift+Enter, or by running

roxygen2::roxygenize()

The project is set up to do this whenever building and testing the package.


Other

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.