mirror of
https://github.com/hanzoai/rustautogui.git
synced 2026-10-30 18:23:05 +00:00
* opencl first buggy implementation * more work on opencl. Buggy atm * WORKING ALGORITHM ATM but slow * working opencl code with implemented 2 step fully * first reworks. addition of new fields in struct and some cleanup * more changes. added a struct for memory buffers, creation of it, new functions for gui dedicated opencl template match * more changes, no errors * added to main functions in lib. Not tested yet * first tests done, code working. Needs more optimisation * some testing prints, code retested after fix in time measurement. Looks promising * revert back * tested optimisations reimplemented and working * a bit more optimisations * added opencl feature * fmt * added change ocl state, graceful exits * windows fix * small optimisation * macos fix * different variations of tests * currently a fine solution to auto determine treshold of fast segmentation * derivative activation only in opencl mode * readme update * add v2 algorithm * added table of contents to readme * update changelog (no date included yet) * moved all the additional v2 buffers under GpuMemoryPointers struct * additional work on v2 * unifying v1 and v2 kernels + other data * working on adding devices info * more work done on detecting devices, creating kernels and moving kernels to precalculated * working state of code. Implemented different OCL things, Kernel building outside of OCL Kernel storage, most of logic for V2. * added v2 into logic. remaining to create standalone lib.rs functions * various fixes * added precision to buffer passed to GPU and updated * adding more matchmodes and covering * cleaning up code * moving some enums to structs * changes on lots of stuff, including changing device for OCL * implemented lite feature * changes on lite code, removed problems * renamed template match * cleaned unnecesary conditions * fixed issue with memory not cleaned up on v2 * readme update and fix on matchmode * fix for region on ocl matching * fixes for ltie mode * added opencl example * fix for v2 opencl * fix on opencl device choice to not take cpu * lite fixes on macos * linux fixes * windows fix * moved files to CORE folder * full code restructure * full code restructure * started with testing * more tests * additional mac tests * linux additions * linux fixes + cargo.toml editing * more fixes * clippy fixes * github action update --------- Co-authored-by: DavorMar <[email protected]>
97 lines
3.5 KiB
Rust
97 lines
3.5 KiB
Rust
// code that opens chrome, new tab, goes to github, mouse overs star (click commented out), scrolls to the bottom and clicks on terms
|
|
// no image files included for examples
|
|
|
|
fn main() {
|
|
#[cfg(not(feature = "lite"))]
|
|
{
|
|
use rustautogui::RustAutoGui;
|
|
use std::thread;
|
|
use std::time;
|
|
let mut rustautogui = RustAutoGui::new(false).unwrap(); // initialize
|
|
let (screen_w, screen_h) = rustautogui.get_screen_size();
|
|
|
|
// load, process and store image of star(can be image of project name text)
|
|
// regions are written in this way to cover any screen size, not hardcoding them
|
|
rustautogui
|
|
.store_template_from_file(
|
|
"/home/davor/Pictures/stars.png",
|
|
Some((
|
|
(0.2 * screen_w as f32) as u32, // start x
|
|
0, // start y
|
|
(0.5 * screen_w as f32) as u32, // width
|
|
(0.4 * screen_h as f32) as u32, // height
|
|
)),
|
|
rustautogui::MatchMode::Segmented,
|
|
"stars",
|
|
)
|
|
.unwrap();
|
|
|
|
// just for example doing single prepare, but you would want to store it also
|
|
// load, process and store image of terms
|
|
rustautogui
|
|
.prepare_template_from_file(
|
|
"/home/davor/Pictures/terms.png",
|
|
Some((
|
|
(0.1 * screen_w as f32) as u32, // start x
|
|
(0.7 * screen_h as f32) as u32, // start y
|
|
(0.5 * screen_w as f32) as u32, // width
|
|
(0.3 * screen_h as f32) as u32, // height
|
|
)),
|
|
rustautogui::MatchMode::Segmented,
|
|
)
|
|
.unwrap();
|
|
|
|
// press windows/super key
|
|
rustautogui.keyboard_command("win").unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
|
|
// write in chrome
|
|
rustautogui.keyboard_input("chrome").unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
|
|
// run chrome with clicking return/enter
|
|
rustautogui.keyboard_command("return").unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
|
|
// open new tab with ctrl+t
|
|
rustautogui.keyboard_multi_key("ctrl", "t", None).unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
|
|
// input github in url (url input area selected automatically by new tab opening)
|
|
rustautogui
|
|
.keyboard_input("https://github.com/DavorMar/rustautogui")
|
|
.unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
|
|
// return/enter to open github
|
|
rustautogui.keyboard_command("return").unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
|
|
// loop till image of star is found or timeout of 15 seconds is hit
|
|
rustautogui
|
|
.loop_find_stored_image_on_screen_and_move_mouse(0.95, 1.0, 15, "stars")
|
|
.unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
// rustautogui.left_click().unwrap();
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
|
|
// scroll down 80 times to the bottom of the page where small terms button is
|
|
rustautogui.scroll_down(80).unwrap();
|
|
|
|
// loop till image found with timeout of 15 seconds
|
|
rustautogui
|
|
.loop_find_image_on_screen_and_move_mouse(0.95, 1.0, 15)
|
|
.unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(500));
|
|
rustautogui.left_click().unwrap();
|
|
}
|
|
}
|