How could I return the result (of Applescript) to next workflow ?

Hi everyone, sorry for I am a newbie in Applescript & Automator.

I had been created a workflow (using Applescript) to get snapshot from some website (by Firefox+Add-on “page saver” +hotkey).
But I wish to pass the image to next step of workflow for another process.

How do I do next ?


	tell application "Firefox"
		open location "http://xxx.xxx.xxx"
		activate

        	tell application "System Events"
			keystroke "d" using {control down}
			-- take snapshot
		end tell
		delay 2
		close every window of application "Firefox"
		tell application "System Events"
			keystroke return
		end tell
	end tell

Where is the image ?

“Mac OS:Users:YANG:Pictures:webpage:”

thanks for your attention.

the code of an AppleScript action is wrapped with


on run {input, parameters}
	
	(* Your script goes here *)
	
	return input
end run

if you want to return the reference the webpage folder write

on run {input, parameters}
	
	(* Your script goes here *)
	set webPageFolder to alias ((path to pictures folder as text) & "webpages:")
	return webPageFolder
end run

thanks for your reply. But the script return the “Folder” not the “File” (image) created by the script.

I had tried to add another script:


tell application "Finder"
   set theItems to every file of folder "Mac OS:Users:YANG:Pictures:webpage:"
   set theItems to (sort theItems by name)
   set theNames to {}
   repeat with oneFile in theItems
      set theNames to oneFile
   end repeat
end tell

That which identified the last items (I supposed to be the last created file) of the folder. But actually, I didn’t certainly sure that was the file I wish. And also, I don’t known how to do next step, to returned result (eg. the File) to next step of workflow.

You could retrieve a list of all file names before doing the sanpshot.
Then the new file is not in the list of names and you can return the alias specifier of the file


set webPageFolder to (path to pictures folder as text) & "webpage:"
tell application "Finder" to set nameList to name of files of folder webPageFolder
-- do snapshot

tell application "Finder" to set newItem to 1st file of folder webPageFolder whose name is not in nameList
return (newItem as alias)

That seemed to be a good resolution. Thank you very much. :slight_smile:

By the way, I don’t know the difference between script:
[ tell application “Finder” to set … ]
and
[ tell application “Finder”
set … ]

could anybody help me this stupid question ?

it’s the same thing with a different syntax.
The latter can be used if the Finder terminology fits into one line

tell application "Finder"
	doSomething()
end tell
tell application "Finder" to doSomething()

I appreciated your answer…

If I want to retrieved some URLs from some websites (ex. some tag from http://del.icio.us) and wish to take snapshot of those website by the way described above, how could I do next ??

till now, I only could use some action in the automator apps. let’s me described the workflow …

1st step : get specific URLs (sorry if i didn’t use the precise name of the action, because my Mac mini is Chinese language) (and here I gave the automator the URL of the tag of http://del.icio.us)
2nd step : get linked URL from the website
3rd step : Filter URL (So I can get the URL of bookmarks from the tag)
4th step : ?? how to process the input by Firefox ??