• 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: Unable to target a specific UI element in Preview.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unable to target a specific UI element in Preview.app


  • Subject: Re: Unable to target a specific UI element in Preview.app
  • From: Axel Luttgens <email@hidden>
  • Date: Sun, 17 Apr 2016 14:04:30 +0200

> Le 17 avr. 2016 à 11:19, Yvan KOENIG a écrit :
>
> […]
>
> Hello Axel
>
> When running El Capitan, there is no text field in the splitter group so your script returns :
>
> error "Erreur dans System Events : Il est impossible d’obtenir text field 1 of splitter group 1 of window 1 of application process \"Preview\". Index non valable." number -1719 from text field 1 of splitter group 1 of window 1 of application process "Preview"

Hello Yvan,

I tried my script under El Capitan, and it works there too.
Well, kind of.

In fact, I now better understand the OP’s problem: the side bar *must* be shown in Preview’s window for the text field to be accessible thru UI scripting. I didn’t notice, because I usually have the side bar visible in Preview.

So, let’s try to circumvent the bug:

tell application "Preview" to activate
delay 1
tell application "System Events"
	tell application process "Preview"
		tell front window
			tell splitter group 1
				set hadSidebar to exists scroll area 2
			end tell
		end tell
		if not hadSidebar then
			click menu item 2 of menu 1 of menu bar item 5 of menu bar 1
			delay 1
		end if
		tell front window
			tell splitter group 1
				tell text field 1
					set focused to true
					set value to "test"
				end tell
			end tell
		end tell
		keystroke return
		if not hadSidebar then
			click menu item 1 of menu 1 of menu bar item 5 of menu bar 1
		end if
	end tell
end tell

With an additional generous delay… Of course, should they prove too invasive, those delays could be replaced with loops testing for the materialization of the expected UI elements.

Seems to be working under both Yosemite and El Capitan.

HTH,
Axel


 _______________________________________________
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: Unable to target a specific UI element in Preview.app
      • From: Yvan KOENIG <email@hidden>
References: 
 >Re: Unable to target a specific UI element in Preview.app (From: Axel Luttgens <email@hidden>)
 >Re: Unable to target a specific UI element in Preview.app (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Unable to target a specific UI element in Preview.app
  • Next by Date: Re: Unable to target a specific UI element in Preview.app
  • Previous by thread: Re: Unable to target a specific UI element in Preview.app
  • Next by thread: Re: Unable to target a specific UI element in Preview.app
  • Index(es):
    • Date
    • Thread