Noct

Struct Noct 

Source
pub struct Noct { /* private fields */ }
Expand description

The main struct for handling the event emitting

Implementations§

Source§

impl Noct

Source

pub fn delay(&self) -> u64

Get the delay per keypress. Default value is 12000. This is Linux-specific.

Source

pub fn set_delay(&mut self, delay: u64)

Set the delay per keypress. This is Linux-specific.

Source§

impl Noct

Source

pub fn new() -> Self

Constructs a new Noct instance.

§Example
use noct::*;
let mut noct = Noct::new();
Examples found in repository?
examples/key.rs (line 7)
5fn main() {
6    thread::sleep(Duration::from_secs(2));
7    let mut noct = Noct::new();
8
9    noct.key_down(Key::Layout('a'));
10    thread::sleep(Duration::from_secs(1));
11    noct.key_up(Key::Layout('a'));
12}
More examples
Hide additional examples
examples/dsl.rs (line 7)
5fn main() {
6    thread::sleep(Duration::from_secs(2));
7    let mut noct = Noct::new();
8
9    // write text and select all
10    noct.key_sequence_parse("{+UNICODE}{{Hello World!}} ❤️{-UNICODE}{+CTRL}a{-CTRL}");
11}
examples/keyboard.rs (line 7)
5fn main() {
6    thread::sleep(Duration::from_secs(2));
7    let mut noct = Noct::new();
8
9    // write text
10    noct.key_sequence("Hello World! here is a lot of text  ❤️");
11
12    // select all
13    noct.key_down(Key::Control);
14    noct.key_click(Key::Layout('a'));
15    noct.key_up(Key::Control);
16}
examples/timer.rs (line 8)
6fn main() {
7    thread::sleep(Duration::from_secs(2));
8    let mut noct = Noct::new();
9
10    let now = Instant::now();
11
12    // write text
13    noct.key_sequence("Hello World! ❤️");
14
15    let time = now.elapsed();
16    println!("{:?}", time);
17
18    // select all
19    noct.key_down(Key::Control);
20    noct.key_click(Key::Layout('a'));
21    noct.key_up(Key::Control);
22}
examples/mouse.rs (line 7)
5fn main() {
6    let wait_time = Duration::from_secs(2);
7    let mut noct = Noct::new();
8
9    thread::sleep(wait_time);
10
11    noct.mouse_move_to(500, 200);
12    thread::sleep(wait_time);
13
14    noct.mouse_down(MouseButton::Left);
15    thread::sleep(wait_time);
16
17    noct.mouse_move_relative(100, 100);
18    thread::sleep(wait_time);
19
20    noct.mouse_up(MouseButton::Left);
21    thread::sleep(wait_time);
22
23    noct.mouse_click(MouseButton::Left);
24    thread::sleep(wait_time);
25
26    noct.mouse_scroll_x(2);
27    thread::sleep(wait_time);
28
29    noct.mouse_scroll_x(-2);
30    thread::sleep(wait_time);
31
32    noct.mouse_scroll_y(2);
33    thread::sleep(wait_time);
34
35    noct.mouse_scroll_y(-2);
36    thread::sleep(wait_time);
37}

Trait Implementations§

Source§

impl Debug for Noct

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Noct

Source§

fn default() -> Self

Create a new Noct instance

Source§

impl Drop for Noct

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl KeyboardControllable for Noct

Source§

fn key_sequence(&mut self, sequence: &str)

Types the string Read more
Source§

fn key_down(&mut self, key: Key)

presses a given key down
Source§

fn key_up(&mut self, key: Key)

release a given key formally pressed down by key_down
Source§

fn key_click(&mut self, key: Key)

Much like the key_down and key_up function they’re just invoked consecutively
Source§

fn key_sequence_parse(&mut self, sequence: &str)
where Self: Sized,

Types the string parsed with DSL. Read more
Source§

fn key_sequence_parse_try(&mut self, sequence: &str) -> Result<(), ParseError>
where Self: Sized,

Same as key_sequence_parse except returns any errors
Source§

impl MouseControllable for Noct

Source§

fn mouse_move_to(&mut self, x: i32, y: i32)

Lets the mouse cursor move to the specified x and y coordinates. Read more
Source§

fn mouse_move_relative(&mut self, x: i32, y: i32)

Lets the mouse cursor move the specified amount in the x and y direction. Read more
Source§

fn mouse_down(&mut self, button: MouseButton)

Push down one of the mouse buttons Read more
Source§

fn mouse_up(&mut self, button: MouseButton)

Lift up a pushed down mouse button Read more
Source§

fn mouse_click(&mut self, button: MouseButton)

Click a mouse button Read more
Source§

fn mouse_scroll_x(&mut self, length: i32)

Scroll the mouse (wheel) left or right Read more
Source§

fn mouse_scroll_y(&mut self, length: i32)

Scroll the mouse (wheel) up or down Read more
Source§

impl Send for Noct

Auto Trait Implementations§

§

impl Freeze for Noct

§

impl RefUnwindSafe for Noct

§

impl !Sync for Noct

§

impl Unpin for Noct

§

impl UnwindSafe for Noct

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.