Class: AX::SystemWide
- Includes:
- Accessibility::String
- Defined in:
- lib/ax/systemwide.rb
Overview
Represents the special SystemWide
accessibility object.
Previously, this object was a singleton, but that apparently causes problems with the AXAPIs. So you should always create a new instance of the system wide object when you need to use it (even though they are all the same thing).
Instance Method Summary collapse
-
#element_at(point) ⇒ AX::Element?
Find the element in at the given point for the topmost appilcation window.
-
#hold_modifier(key) ⇒ Number?
Press the given modifier key and hold it down while yielding to the given block.
-
#initialize ⇒ SystemWide
constructor
Overridden since there is only one way to get the element ref.
-
#on_notification(*args) ⇒ Object
Raises an
NoMethodError
instead of (possibly) silently failing to register for a notification. -
#search(*args) ⇒ Object
The system wide object cannot be used to perform searches.
-
#set_global_timeout(seconds) ⇒ Number
Set the global messaging timeout.
-
#type(string) ⇒ Boolean
(also: #type_string)
Generate keyboard events by simulating keyboard input.
Methods included from Accessibility::String
Methods inherited from Element
#==, #actions, #ancestor, #ancestry, #application, #attribute, #attributes, #blank?, #bounds, #children, #description, #inspect, #inspect_subtree, #invalid?, #method_missing, #methods, #parameterized_attribute, #parameterized_attributes, #perform, #pid, #respond_to?, #set, #size_of, #to_point, #to_s, #writable?
Methods included from Accessibility::Factory
Methods included from Accessibility::PPInspector
#pp_checkbox, #pp_children, #pp_identifier, #pp_position
Constructor Details
#initialize ⇒ SystemWide
Overridden since there is only one way to get the element ref.
16 17 18 |
# File 'lib/ax/systemwide.rb', line 16 def initialize super AXUIElementCreateSystemWide() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AX::Element
Instance Method Details
#element_at(point) ⇒ AX::Element?
Find the element in at the given point for the topmost appilcation window.
nil
will be returned if there was nothing at that point.
83 84 85 |
# File 'lib/ax/systemwide.rb', line 83 def element_at point process @ref.element_at point end |
#hold_modifier(key) ⇒ Number?
Press the given modifier key and hold it down while yielding to the given block.
49 50 51 52 53 54 55 56 57 |
# File 'lib/ax/systemwide.rb', line 49 def hold_modifier key code = EventGenerator::CUSTOM[key] raise ArgumentError, "Invalid modifier `#{key}' given" unless code @ref.post [[code, true]] yield ensure # if block raises the button might stuck, so ensure it is released @ref.post [[code,false]] if code code end |
#on_notification(*args) ⇒ Object
Raises an NoMethodError
instead of (possibly) silently failing to
register for a notification.
71 72 73 |
# File 'lib/ax/systemwide.rb', line 71 def on_notification *args raise NoMethodError, 'AX::SystemWide cannot register for notifications' end |
#search(*args) ⇒ Object
The system wide object cannot be used to perform searches. This method is just an override to avoid a difficult to understand error messages.
62 63 64 |
# File 'lib/ax/systemwide.rb', line 62 def search *args raise NoMethodError, 'AX::SystemWide cannot search' end |
#set_global_timeout(seconds) ⇒ Number
Set the global messaging timeout. Searching through another interface and looking up attributes incurs a lot of IPC calls and sometimes an app is slow to respond.
94 95 96 |
# File 'lib/ax/systemwide.rb', line 94 def set_global_timeout seconds @ref.set_timeout_to seconds end |
#type(string) ⇒ Boolean Also known as: type_string
With the SystemWide
class, using #type will send the
events to which ever app has focus.
Generate keyboard events by simulating keyboard input.
See the Keyboarding documentation for more information on how to format strings.
31 32 33 34 |
# File 'lib/ax/systemwide.rb', line 31 def type string @ref.post keyboard_events_for string true end |