Expand description
Real input for checks: clicks and keystrokes that take the path a user’s
do, not AppKit’s entry points (performClick, selectRowIndexes).
Two kinds:
- Event-queue input (
click,type_text,key…): mouse and key events posted to the app’s own event queue. AppKit dispatches them as it dispatches the window server’s:sendEvent, hit-testing, key equivalents through the menus, the first responder, the field editor and text input. They need the app active and the window key (seeready); no permission. - Window-server input (
server_click,server_type):CGEvents posted to this process, through the window server like a real keyboard and mouse, without moving the pointer. They need the process to be trusted for Accessibility (System Settings › Privacy & Security › Accessibility, for the terminal that runs the checks):server_availablesays whether it is. Checks skip them, and say so, when it isn’t.
Events are delivered on the run loop’s next turns: check their effect a moment later.
Enums§
Functions§
- click
- Clicks the middle of
view, as the user would: the window hit-tests the point, so whatever is on top there gets the click. - click_
at - Clicks
viewatx, ypoints from its top-left corner. - click_
at_ with - Clicks
viewatx, ypoints from its top-left corner, holdingmods. - double_
click - Double-clicks the middle of
view. - key
- Presses
keywithmodsinwindow(to its first responder, or the menus’ key equivalents when ⌘ is held). - ready
- Brings the app to the front and makes
windowkey, so input reaches it. True once both hold (it can take a run-loop turn: call it, wait a moment, and call it again before sending input). - server_
available - Whether window-server input can be posted: this process is trusted for Accessibility. (Asking for it is the user’s to do, in System Settings.)
- server_
click - Clicks the middle of
viewthrough the window server (see the module docs); false if that isn’t available. - server_
type - Types
textthrough the window server (see the module docs); false if that isn’t available. - type_
text - Types
textintowindow’s first responder, a key at a time (capitals with ⇧, line breaks as Return).