0

I want to write code in appscript.rb equivalent to Applescript:

tell App "TextEdit"
    properties of front window
end tell

Trying

te =  app("TextEdit")
puts        te.windows[1].properties

returns the list of property names but no value.

Thanks to answer.

TheMaster
  • 45,448
  • 6
  • 62
  • 85

1 Answers1

0

The Ruby Appscript equivalent to AppleScript’s properties reference has a trailing underscore: properties_. You will also need to use get to execute the query:

te = Appscript.app('TextEdit')
te.windows.first.properties_.get

The result of the last expression will be an instance of Ruby’s Hash class.


The title of your question mentions UI_element, which might indicate that you are interested in the UI elements objects available from System Events.

se = Appscript.app('System Events')
teap = se.application_processes['TextEdit']

# properties of frontmost UI element window
teap.windows.first.properties_.get

# properties of first-level UI elements of frontmost UI element window 
teap.windows.first.UI_elements.properties_.get
Chris Johnsen
  • 214,407
  • 26
  • 209
  • 186