Giter VIP home page Giter VIP logo

enigo's People

Contributors

8176135 avatar as-f avatar billyb2 avatar brettmayson avatar chengyuhui avatar dependabot[bot] avatar dtibbs avatar eijebong avatar framp avatar hatamiarash7 avatar isharedx avatar jd91mzm2 avatar klapovav avatar mantou132 avatar micolous avatar najamelan avatar naokim03 avatar obv-mikhail avatar paulora2405 avatar pentamassiv avatar pierre-l avatar pythoneer avatar rukai avatar santiagocezar avatar shaybox avatar simonvandel avatar sphaerophoria avatar tbodt avatar trishume avatar zeldern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enigo's Issues

Add Serde support

Implement Serde Serialize and Deserialize traits for Key and MouseButton as optional feature (like in the uuid crate).

Fetch peripherals data from system

use data about the system like (screen size, number of connected monitors, mouse position etc) and make it accessible through public API. Possibly API changes for eg. moving the mouse to let the user choose the monitor.

should solve issues #40 #27 #26

Linux doesn't press any non-alphanumeric keys

If you send any non-alphanumeric key, enigo seems to just send it directly to xdotool, which it doesn't accept. (it just gives the error Error: Invalid key sequence '.' or Failure converting key sequence '.' to keycodes).
List of keys affected:

`
-
=
[
]
\
;
'
,
.
/

I think I can make a PR to fix this.

Keyboard DSL

Think about a DSL for Keyboard input beyond "just" plain Text.

Listening to events

Hi!
Is there a way to listen to input events? If not, is there a plan to implement it?

Sending characer sequences is slow

First off let me say that I'm using linux.

I'd like to use this library to control the keyboard programmatically while the user is typing. I really like the API, but sending a character sequence takes a long time, at least 40ms per character due to sleeping 10ms before and after every keydown and keyup, so a single word can easily take half a second to print.

I tried forking and changing those sleep values but if it's too short, not all of the characters print, so I'm guessing they're there for good reason.

I've been looking at plover, which is implemented in python. In plover, they also use XTest to send character sequences, but they render almost instantaneously. I can hammer keys as fast as I can and plover can easily keep up, turning single keystrokes into multi word sequences.
See here https://github.com/openstenoproject/plover/blob/master/plover/oslayer/xkeyboardcontrol.py#L1223

They don't appear to be flushing after every keydown and keyup, but instead appear to be calling display.sync at the end of the key sequence. Is there any way enigo can print entire key sequences instantaneously or is there some limitation there?

Private Fields

Make the Fields in the Enigo struct private ... i don't think they need to be public.

Linking error `cannot find -lxdo` when trying to compile 0.0.12 on Linux

After upgrading to 0.0.12 from 0.0.11, when I try to compile on Linux (works fine on gnu Windows) it gives error: linking with `cc` failed: exit code: 1 and the reason note: /usr/bin/ld: cannot find -lxdo

The only change to dependencies in 0.0.12 that seem to affect linux is objc 0.2.2, but when I tried to compile that by itself, it compiled just fine.

I also installed xdo, but that didn't seem to change anything.

Any ideas?

Support more buttons in DSL

The DSL has a limited amount of buttons that it currently supports. In the first iteration i think its a good idea to support all layout independent ones.

Umlauts not working

extern crate enigo;
use enigo::{Enigo, KeyboardControllable, Key};
use std::thread;
use std::time::Duration;

fn main() {
    thread::sleep(Duration::from_secs(2));
    let mut enigo = Enigo::new();

    enigo.key_click(Key::Layout("ä".into()));
}

Mouse on multiple monitors

Currently mouse_move doesn't take a screen parameter, which is necessary to be able to specify which monitor.

Better Installation Instructions for Arch Linux

OS: Arch Linux
Enigo version: 0.0.12
I kept getting a linker error (/usr/bin/ld: cannot find -lxdo) when building a very simple program, specifically this one:

extern crate enigo;
use enigo::{Enigo, MouseControllable};

fn main() {
    let mut enigo = Enigo::new();
    enigo.mouse_move_to(500, 200);
}

The error read:

/usr/bin/ld: cannot find -lxdo

on Arch Linux, packages are named differently from Ubuntu. apt install libxdo-dev (the recommendation from the readme) does not help. To get this working on arch, I had to use

pacman -S xdotool

This command should probably be added to the README. It took me several minutes to discover the right package to install through trial and error, and I thought the enigo crate might simply not work on Arch.

Listen to User Events

Hi, is there is a way to listen to user events. e.g Keyboard events or mouse clicks?
currently i need to listen to some hotkeys e.g "Capslock" toggled so i can make some actions against it.

Thank you.

Reason about a general delay

In issue #38 we had come to the conclusion that it is beneficial to have a general way to let the user set a way to delay input. It is maybe reasonable to just use the current way it is implemented in linux and make it accessible through the [KeyboardControllable trait](https://github.com/enigo-rs/enigo/blob/949da7042904921530d27a19ebcb2e7bb3615839/src/lib.rs#L330)

Add missing keys

Hi.
There's a few missing keys like:

  • Delete
  • End

Thanks to add them.

crash in linux version

if i let this code run, the program crashes

    enigo.key_sequence("ä#+ -> hello world ... 𝕊");

    enigo.key_click(Key::RETURN);
    enigo.key_click(Key::RETURN);
    enigo.key_click(Key::RETURN);
    enigo.key_click(Key::RETURN);
    enigo.key_click(Key::RETURN);

    enigo.key_sequence("... how are you? ❤️");

with this error message

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  132 (XTEST)
  Minor opcode of failed request:  2 (X_XTestFakeInput)
  Value in failed request:  0x0
  Serial number of failed request:  120
  Current serial number in output stream:  122

enigo::Enigo::key_sequence too fast in release mode

this library behaves differently in release mode vs debug mode.

In debug mode it is quite slow at typing -- it takes around 2-3 seconds to type 20 characters on my laptop.

However, in release mode nothing happens at all! I think the compiler might be optimizing a function away.

Workaround

I found that the following works in release mode:

fn is_uppercase(c: char) -> bool {
    match c {                                                                                                                                                                                                     
        'A' ... 'Z' => true,                                                                                                                                                                                      
        _ => false,
    }
}

    let mut enigo = enigo::Enigo::new();
    println!("sending: {}", password.audit_this);
    for c in password.audit_this.chars() {
        println!("key: {}", c.to_string());
        if is_uppercase(c) {
            enigo.key_down(enigo::Key::Shift);
        }
        enigo.key_down(enigo::Key::Layout(c.to_string()));
        enigo.key_up(enigo::Key::Layout(c.to_string()));
        if is_uppercase(c) {
            enigo.key_up(enigo::Key::Shift);
        }
    }

It is still rather slow at typing but it works. I wish there were some way to improve the speed.

Add delay

let the user choose a delay in the public api (only keyboard or for any input?)

Interior mutability

use interior mutability to alter internal fields. It is un-ergonomic to bind Enigo mutably.

test

just to test the Discord webhook

Use streams :D

In the Gitter chat, me and @pythoneer (lead dev) decided using streams for this would be cool.

Imagine something like this: write!(enigo::out, "{}h{}ello {}w{}orld", enigo::shift_on, enigo::shift_off, enigo::shift_on, enigo::shift_off)

Mousebutton Enum

use an enum for the Mousebutton constants (1=left, 2=right) etc.

Update/Cleanup

  • lift the codebase up to Rust 2018 Edition
  • update dependencies if necessary
  • clippy run
  • rustfmt run

Mac key_sequence limited to 20 characters

It looks like CGEventKeyboardSetUnicodeString truncates strings down to 20 characters, and is undocumented. A few links of other individuals running into this problem:

https://apple.stackexchange.com/a/289046
https://forum.qt.io/topic/46579/cgeventkeyboardsetunicodestring-will-only-process-up-to-20-characters

Is this something we could handle at the enigo mac implementation level? e.g. split key sequence strings into 20 characters and send them in succession?

Should be possible to specify modifiers

Hi.
On Linux and a GTK application, sending a key_down(Shift) won't trigger the key-press-event for the shift key and thus, the text won't be entered in uppercase.
Could you please add an option to specify the modifier keys so that I could send a character with the Shift modifier?
Thank you.

Bound check mouse

investigate how to bound check the mouse cursor (is this necessary? does that cause errors/panics?)

Add basic derived Traits where possible to the enigo data structures

I found myself wanting to create a struct which held a field of type enigo::Key, so it could pass this every time it has to call an enigo function like key_up. Unfortunately methods like this one take ownership of the key that one sends in (which is probably a bad idea in itself), and the enum does not derive "Copy, Clone" or other basic traits, and Copy no longer is implicit nowadays.

Practically this means that a user has to hard code which key they want to send and can't store it in a variable, since it can't be copied...

I kind of didn't find any way to work around this except modifying enigo. I will make a pull request for enigo::Key, but other data structures might be affected as well.

Make `Cargo.toml` OS independent

In the current state it is only possible to build under Linux due to its dependencies. Make it build under macOS, Windows and possibly Redox.

Space (0x20) is an 'Invalid key sequence'

This program on Linux with X11 with xdotool-3.20160805.1 and enigo 0.0.12 gives an error:

    let mut enigo = Enigo::new();
    enigo.key_sequence_parse(" ");
Error: Invalid key sequence ' '
Failure converting key sequence ' ' to keycodes
Error: Invalid key sequence ' '
Failure converting key sequence ' ' to keycodes

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.