Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature mouse commands #448

Merged
merged 13 commits into from
Nov 28, 2023
Merged

Feature mouse commands #448

merged 13 commits into from
Nov 28, 2023

Conversation

zenangst
Copy link
Owner

  • Initial feature commit
  • Update designTime.json
  • Improve Mouse-related models Add skeleton NewCommandMouseView
  • Remove duplicate view
  • Continue mouse command implementation
  • Add MouseCommandRunner Bump AXEssibility to version 0.0.9
  • Improved mouse command flexibility with new click location options
  • Improved resolving frame in accessibility element resolvers to return CGRect directly
  • Enhancements to Accessibility Resolvers and Mouse Command Runner:
  • Refactor AXScrollAreaResolver for improved element processing
  • Refactor click location handling in MouseCommand model and XcodeMouseRoutine
  • Add beta annotation to views

Add skeleton NewCommandMouseView
- Finish new mouse command implementation
- Add `MouseCommandView` UI
- Add actions for updating mouse commands
Bump `AXEssibility` to version `0.0.9`
The mouse command models and views have been updated to support specifying the click location within the element. This enhancement adds flexibility for users to define mouse interactions more precisely by choosing from predefined locations (e.g., top, center, bottom) or specifying custom coordinates. This change addresses scenarios where the default click position might not trigger the intended behavior in the UI element.

MouseCommand.Kind now includes an associated ClickLocation enum with various standard positions and a custom coordinate option. Updates to the views ensure that users can select the desired click location via menus and define custom x, y coordinates when needed.

Furthermore, the MouseCommandRunner is adapted to translate the ClickLocation to the actual point on the screen and pass it to the mouse event posting functionality. This helps to simulate user interactions in a more targeted and accurate manner.
… CGRect directly

In our accessibility element resolution strategy, we have refactored multiple resolvers such as AXCollectionResolver, AXGroupResolver, AXListResolver, AXOutlineResolver, AXScrollAreaResolver, and introduced AXTextEntryAreaResolver to directly return the frame (CGRect) of the focused element instead of returning an AnyAccessibilityElement. Previously, we were obtaining an AnyAccessibilityElement and then extracting its frame which was an unnecessary intermediate step. This change simplifies the API and directly provides the essential data needed for further processing. Additionally, the MouseCommandRunner has been updated to handle the new return type and to consider the newly added case .textEntryArea while resolving the frame. The added error case in MouseCommandRunnerError ensures that an appropriate error is thrown when a frame cannot be resolved, enhancing error handling.
Improved support for accessibility elements and mouse actions by introducing a variety of new resolvers and refining existing ones. This commit provides better handling of different content areas exposed via accessibility APIs and more accurately targets mouse events based on context.

- Introduced `AXEditorResolver`, `AXHTMLResolver`, and `AXTableResolver` to handle specific types of UI elements, improving the targeting of mouse actions.
- Updated `AXGroupResolver` to default to the parent element if no match is found within the group.
- Created `CustomMouseRoutine` and associated classes to handle custom mouse routines for specific applications identified by bundle identifiers. An example being Xcode, in which a specialized routine calculates mouse target locations within the text entry area.
- Refined `MouseCommandRunner` to integrate new resolver logic, including support for the new `AXHTMLResolver`.
- Ensured the mouse is moved back to its original location after a command is executed to maintain user cursor context.
- Added logic to `UserSpace` for obtaining selected text from web content via clipboard manipulation, accommodating cases where direct access to selected text is not possible through accessibility APIs.

These enhancements provide a framework to extend and customize mouse interactions within various applications, ensuring a smoother user experience when automating tasks that rely on precise element targeting and mouse events.
Optimized the element resolution process in AXScrollAreaResolver by extracting and refactoring the logic of checking for focused or selected elements into a separate, recursive function. This enhances maintainability and readability of the code by reducing complexity within the resolveFocusedElement function and centralizing the decision-making process for finding the correct element.
…Routine

To improve the maintainability and extendibility of the MouseCommand model, we've refactored the way click locations are accessed and modified. The MouseCommand.UIElement enum now includes a computed property for directly getting and setting the ClickLocation without duplicating switch-case logic. Additionally, the XcodeMouseRoutine has been updated to utilize this new property, streamlining the logic for frame calculations and making it easier to add new click location behaviors in the future. This change promotes cleaner code practices and prepares for potential feature expansion.
Copy link

Copy link

@zenangst zenangst merged commit 7457148 into main Nov 28, 2023
2 checks passed
@zenangst zenangst deleted the feature/mouse-commands branch November 28, 2023 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant