• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: coercing results of UI elements to paragraph delimited list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coercing results of UI elements to paragraph delimited list


  • Subject: Re: coercing results of UI elements to paragraph delimited list
  • From: "koenig.yvan" <email@hidden>
  • Date: Sat, 13 Jul 2013 18:08:33 +0200


Le 13/07/2013 à 13:57, 2551 <2551phil@gmail.com> a écrit :

Friends

When exploring UI elements in AS Editor, the result typically comes back as something like this:

{menu bar item "Apple" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "Scrivener" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "File" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "Edit" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "View" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "Project" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "Documents" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "Format" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "Window" of menu bar 1 of application process "Scrivener" of application "System Events", menu bar item "Help" of menu bar 1 of application process "Scrivener" of application "System Events"}

Is there some trick handler I can throw in the script so that what appears in the result window formats each comma delimited result on a new line, i.e, like this:

{menu bar item "Apple" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "Scrivener" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "File" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "Edit" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "View" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "Project" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "Documents" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "Format" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "Window" of menu bar 1 of application process "Scrivener" of application "System Events”, 
menu bar item "Help" of menu bar 1 of application process "Scrivener" of application "System Events”}



Whenever I try the usual tricks, I always get back the error that I can’t coerce this result into a list, string, text, etc.

Thanks in advance!

Alternate way.

Save this short script in an application.
For my own tests I named it cafteur.app

Run the script grabbing the wanted infos from the script editors with the log report area opened to display the Result.

Double click the application cafteur.app.
The clipboard will contain the wanted datas as text.

example :
if you execute

activate application "AppleScript Editor"
tell application "System Events" to tell process "AppleScript Editor"
tell text area 1 of scroll area 1 of group 1 of group 1 of splitter group 1 of window 1
value of attribute "AXValue"
end tell
end tell

my remplace(result, ",", return)
set the clipboard to result

#=====
(*
replaces every occurences of d1 by d2 in the text t
*)
on remplace(t, d1, d2)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d1}
set l to text items of t
set AppleScript's text item delimiters to d2
set t to "" & l
set AppleScript's text item delimiters to oTIDs
return t
end remplace

#=====

you will get :

{menu bar item "Apple" of menu bar 1 of application process "Finder" of application "System Events"
 menu bar item "Finder" of menu bar 1 of application process "Finder" of application "System Events"
 menu bar item "Fichier" of menu bar 1 of application process "Finder" of application "System Events"
 menu bar item "Édition" of menu bar 1 of application process "Finder" of application "System Events"
 menu bar item "Présentation" of menu bar 1 of application process "Finder" of application "System Events"
 menu bar item "Aller" of menu bar 1 of application process "Finder" of application "System Events"
 menu bar item "Fenêtre" of menu bar 1 of application process "Finder" of application "System Events"
 menu bar item "Aide" of menu bar 1 of application process "Finder" of application "System Events"}


I'm too lazy to remove the starting and ending characters.

KOENIG Yvan (VALLAURIS, France) samedi 13 juillet 2013 18:08:25



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: coercing results of UI elements to paragraph delimited list
      • From: 2551 <email@hidden>
References: 
 >coercing results of UI elements to paragraph delimited list (From: 2551 <email@hidden>)

  • Prev by Date: Re: coercing results of UI elements to paragraph delimited list
  • Next by Date: Re: coercing results of UI elements to paragraph delimited list
  • Previous by thread: Re: coercing results of UI elements to paragraph delimited list
  • Next by thread: Re: coercing results of UI elements to paragraph delimited list
  • Index(es):
    • Date
    • Thread