Created
January 28, 2017 23:07
-
-
Save dustyfresh/20369c2c98a953282886c8f5782eb89b to your computer and use it in GitHub Desktop.
click fast!
This file contains hidden or 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
| /* cargo.toml | |
| [package] | |
| name = "clicker" | |
| version = "0.1.0" | |
| authors = ["dustyfresh"] | |
| [dependencies] | |
| keystroke = "*" | |
| kernel32-sys = "*" | |
| user32-sys = "*" | |
| winapi = "*" | |
| winmm-sys = "*" | |
| mouse_automation = "*" | |
| */ | |
| #[allow(unused_variables)] | |
| extern crate keystroke; | |
| extern crate kernel32; | |
| extern crate user32; | |
| extern crate winapi; | |
| extern crate mouse_automation; | |
| use std::time::Duration; | |
| use std::thread; | |
| use std::process; | |
| use keystroke::{send_str, send_key, send_combo, Key, Physical}; | |
| // To start spam event press the ctrl hotkey, and hold the escape key to stop the spam event | |
| fn main() { | |
| cloak(); | |
| println!("F1 - left-click really fast\nESC - quit"); | |
| loop { | |
| loop { | |
| if unsafe { user32::GetAsyncKeyState(winapi::VK_ESCAPE) } == -32767 { | |
| process::exit(0); | |
| } | |
| if unsafe { user32::GetAsyncKeyState(winapi::VK_F1) } == -32767 { | |
| left_clicky(); | |
| } | |
| } | |
| } | |
| } | |
| // function for hiding the window of the program | |
| fn cloak() { | |
| let mut cloak: winapi::HWND; | |
| unsafe { | |
| kernel32::AllocConsole(); | |
| cloak = user32::FindWindowA(std::ffi::CString::new("ConsoleWindowClass").unwrap().as_ptr(), std::ptr::null()); | |
| user32::ShowWindow(cloak,0); | |
| } | |
| } | |
| // click the left mouse button in a loop really fast | |
| fn left_clicky() { | |
| loop { | |
| if unsafe { user32::GetAsyncKeyState(winapi::VK_ESCAPE) } == -32767 { | |
| break; | |
| } | |
| mouse_automation::LEFT.down(); | |
| mouse_automation::LEFT.up(); | |
| thread::sleep(Duration::from_millis(1)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment