• 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: who owns the dialog box from a print command?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: who owns the dialog box from a print command?


  • Subject: Re: who owns the dialog box from a print command?
  • From: "koenig.yvan" <email@hidden>
  • Date: Sat, 17 Aug 2013 19:32:15 +0200


Le 17/08/2013 à 18:13, Jim Brandt <email@hidden> a écrit :


I am having a problem completing a dialog.

The situation:

From Tex-Edit Plus, I want to save a print version as a PDF file on the desktop. After I have the file as I want it, here is the piece of the script that is supposed to do this:

tell application "System Events" to tell process "Tex-Edit Plus"
click menu item "Print…" of menu 1 of menu bar item "File" of menu bar 1
repeat until exists sheet 1 of window WindowName
delay 0.1
end repeat
click menu button "PDF" of sheet 1 of window WindowName
click menu item "Save as PDF…" of menu of menu button "PDF" of sheet 1 of window WindowName
keystroke "D" using {command down} -- put it on the desktop
click button "Save" of window "Save"
end tell

The problem is the last line, click button "Save" of window "Save". That line is what UI Browser gave me as the AppleScript to select the save button. However, in OS X version 10.7, this window is a seperate dialog box, and the error I'm getting is:

System Events got an error: Can't get window "Save" of process "Tex-Edt Plus"

If this dialog box doesn't belong to Tex-Edit Plus, who does it belong to?

TIA,

Jim


Here is a piece of code which I send in July.

It works well under 10.8.
Not tested under 10.7

My understanding is that you missed a sheet level.
At this time, they are two of them.

set _filename to "Reports"
set _dateStamp to (do shell script "date +_%Y-%m-%d_%H.%M.%S")
set _newName to _filename & _dateStamp & ".pdf"

tell application "System Events"
set appname to name of first process whose frontmost is true
end tell
if appname is "AppleScript Editor" then set appname to "Safari"

activate application appname
tell application "System Events"
tell process appname
set nbw to count windows
-- insert GUI Scripting statements here
keystroke "p" using {command down}
(*
Wait for the availability of the sheet *)
repeat
if exists sheet 1 of window 1 then exit repeat
end repeat
set PDFButton to first menu button of sheet 1 of window 1
click PDFButton
click menu item 2 of menu 1 of PDFButton
(*
Wait for the availability of the Print sheet *)
repeat
if exists sheet 1 of sheet 1 of window 1 then exit repeat
end repeat
(*
Force Desktop as target folder *)
keystroke "d" using {command down}
(*
Set the name of the new PDF *)
set value of text field 1 of sheet 1 of sheet 1 of window 1 to _newName
keystroke return
end tell
end tell

Maybe PDF is not the first menu item when running Text-Edit Plus which I don't own.

I do my best to code without using strings which may be localized as :

Print…
PDF
Save

I guess that PDF is OK for every Roman languages but I don't know for others.

KOENIG Yvan (VALLAURIS, France) samedi 17 août 2013 19:32:09



 _______________________________________________
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

References: 
 >who owns the dialog box from a print command? (From: Jim Brandt <email@hidden>)

  • Prev by Date: who owns the dialog box from a print command?
  • Next by Date: Re: who owns the dialog box from a print command?
  • Previous by thread: who owns the dialog box from a print command?
  • Next by thread: Re: who owns the dialog box from a print command?
  • Index(es):
    • Date
    • Thread