• 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: NSReceiverEvaluationScriptError: 4 interaction with Safari
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSReceiverEvaluationScriptError: 4 interaction with Safari


  • Subject: Re: NSReceiverEvaluationScriptError: 4 interaction with Safari
  • From: KOENIG Yvan <email@hidden>
  • Date: Mon, 4 Aug 2008 20:59:59 +0200


Le 4 août 2008 à 20:44, Sean R. McCorkle a écrit :


Hi Folks,

  I'm desperately trying to program Safari to automatically fetch and
  save a series of web pages and have turned to AppleScript.  I found
  a useful example here

     http://discussions.apple.com/thread.jspa?messageID=7129792

  specifically

tell application "System Events" to tell process "Safari"

keystroke "s" using command down -- 'Command S' - 'Save As...'
delay 1 -- Pause for 1 second.
keystroke "d" using command down -- 'Command D' - Go to 'Desktop'.
delay 1 -- Pause for 1 second.

keystroke "c" using command down -- 'Command C' - Go copy highlighted text.

set the clipboard to ((do shell script ("date +%Y%m%d_%H%M% S_")) & (the clipboard))

keystroke "v" using command down -- 'Command V' - 'Paste'.
delay 1 -- Pause for 1 second.
click button "Save" of sheet 1 of window 1 -- Click on 'Save' button.
end tell



This script runs fine up to the last command. I can watch all the actions
happening up to the pasting of a string into the save filename, but the last
command, "click button" consistently fails with this error


   System Events got an error: NSReceiverEvaluationScriptError: 4

Same behavior on a system running MacOSX 10.3.9 & Safari 1.3.2 (v312.6)
and a system running MacOSX 10.4.11 Safari 3.1.2 (4525.22) (the latter
is the intended system for use)


Can anyone provide some advice? Thanks very much!

I just made a few changes:

tell application "Safari" to activate -- ADDED
tell application "System Events" to tell process "Safari"

keystroke "s" using command down -- 'Command S' - 'Save As...'
delay 1 -- Pause for 1 second.
keystroke "d" using command down -- 'Command D' - Go to 'Desktop'.
delay 1 -- Pause for 1 second.

keystroke "c" using command down -- 'Command C' - Go copy highlighted text.

set the clipboard to ((do shell script ("date +%Y%m%d_%H%M%S_")) & (the clipboard))

keystroke "v" using command down -- 'Command V' - 'Paste'.
delay 1 -- Pause for 1 second.
get name of button 1 of sheet 1 of window 1 -- ADDED to check that button 1 is the correct one
click button 1 of sheet 1 of window 1 -- use the number which is OK worldwide
-- click button "Save" of sheet 1 of window 1 -- Click on 'Save' button. In French it's "Enregistrer"
end tell


Yvan KOENIG (from FRANCE lundi 4 août 2008 20:59:28)


_______________________________________________ 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: 
 >NSReceiverEvaluationScriptError: 4 interaction with Safari (From: email@hidden (Sean R. McCorkle))

  • Prev by Date: NSReceiverEvaluationScriptError: 4 interaction with Safari
  • Next by Date: Re: interaction with Safari
  • Previous by thread: NSReceiverEvaluationScriptError: 4 interaction with Safari
  • Next by thread: NSReceiverEvaluationScriptError: 4 interaction with Safari
  • Index(es):
    • Date
    • Thread