Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/app_engine/interaction.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::AppEngine;
use crate::action::{WordPicker, get_dictionary_attributed_string};
use crate::ax_element::{ElementOfInterest, GetAttribute, SetAttribute};
use crate::config::RoleOfInterest;
use crate::util::Frame;
use crate::{Mode, ScrollAction, TextAction};
use crate::{
Mode, ScrollAction, TextAction,
action::{WordPicker, get_dictionary_attributed_string},
ax_element::{ElementOfInterest, GetAttribute, SetAttribute},
config::RoleOfInterest,
util::Frame,
};
use accessibility::{AXUIElement, AXUIElementActions, AXUIElementAttributes};
use accessibility_sys::{
kAXErrorAttributeUnsupported, kAXErrorCannotComplete, kAXFocusedAttribute,
Expand Down
55 changes: 32 additions & 23 deletions src/app_engine/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl AppEngine {
}
match wf.starting_role {
RoleOfInterest::Any => true,
RoleOfInterest::Some => self.selected.is_some(),
RoleOfInterest::Generic => self
.selected
.as_ref()
Expand Down Expand Up @@ -50,14 +51,16 @@ impl AppEngine {
if self.element_cache.cache.len() == 1 {
self.clear_hints();
self.select(self.element_cache.cache[0].clone());
} else if self.element_cache.cache.len() > 1 {
return true;
} else {
// Stop on empty result
// Stop on empty result/multiple results
return true;
}
return false;
}
WorkFlowAction::Move(x, y) => {
self.move_mouse_with_trail(*x, *y);
return false;
}
WorkFlowAction::KeyCombo(kb) => {
self.set_simulating_key(true);
for k in kb.keys.iter() {
Expand All @@ -82,6 +85,32 @@ impl AppEngine {
return true;
};

let frame = selected.frame;
match act {
WorkFlowAction::Hover => {
let (x, y) = frame.center();
self.move_mouse_with_trail(x, y);
return false;
}
WorkFlowAction::Click => {
let (x, y) = frame.center();
self.simulate_click(x, y, Button::Left);
return false;
}
WorkFlowAction::RightClick => {
let (x, y) = frame.center();
self.simulate_click(x, y, Button::Right);
return false;
}
WorkFlowAction::MiddleClick => {
let (x, y) = frame.center();
self.simulate_click(x, y, Button::Middle);
return false;
}
_ => (),
}

// Actions that require an AX element
let Some(element) = selected.element() else {
self.notify_then_deactivate(
&format!("Running a workflow action with no accessibility element. {act:?}"),
Expand All @@ -92,7 +121,6 @@ impl AppEngine {

let context = &selected.context;
let role = selected.role();
let frame = selected.frame;

match act {
WorkFlowAction::Focus => {
Expand All @@ -102,25 +130,6 @@ impl AppEngine {
let center = frame.center();
self.press_on_element(element, &role, center);
}
WorkFlowAction::Hover => {
let (x, y) = frame.center();
self.move_mouse_with_trail(x, y);
}
WorkFlowAction::Move(x, y) => {
self.move_mouse_with_trail(*x, *y);
}
WorkFlowAction::Click => {
let (x, y) = frame.center();
self.simulate_click(x, y, Button::Left);
}
WorkFlowAction::RightClick => {
let (x, y) = frame.center();
self.simulate_click(x, y, Button::Right);
}
WorkFlowAction::MiddleClick => {
let (x, y) = frame.center();
self.simulate_click(x, y, Button::Middle);
}
WorkFlowAction::ShowMenu => {
let center = frame.center();
self.right_click_menu_on_element(element, center);
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub enum RoleOfInterest {
#[default]
Generic,
Any,
Some,
Image,
MenuItem,
ScrollBar,
Expand Down