Saturday, January 20, 2018
  • Index
  •  » Automator
  •  » How could I return the result (of Applescript) to next workflow ?

#1 2012-02-13 01:50:10 am

mimiba
Member
Registered: 2012-02-12
Posts: 6

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 ?

Applescript:


   tell application "Firefox"
       open location "[url]http://xxx.xxx.xxx[/url]"
       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

Offline

 

#2 2012-02-13 02:30:10 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11483
Website

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

Where is the image ?


regards

Stefan

Offline

 

#3 2012-02-13 03:20:52 am

mimiba
Member
Registered: 2012-02-12
Posts: 6

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

"Mac OS:Users:YANG:Pictures:webpage:"

thanks for your attention.

Offline

 

#4 2012-02-13 03:27:45 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11483
Website

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

the code of an AppleScript action is wrapped with

Applescript:


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

if you want to return the reference the webpage folder write

Applescript:

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

Last edited by StefanK (2012-02-13 03:27:59 am)


regards

Stefan

Offline

 

#5 2012-02-13 04:45:19 am

mimiba
Member
Registered: 2012-02-12
Posts: 6

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

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:

Applescript:


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.

Offline

 

#6 2012-02-13 11:37:47 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11483
Website

Re: How could I return the result (of Applescript) to next 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

Applescript:


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)


regards

Stefan

Offline

 

#7 2012-02-13 06:30:22 pm

mimiba
Member
Registered: 2012-02-12
Posts: 6

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

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

Offline

 

#8 2012-02-13 07:02:35 pm

mimiba
Member
Registered: 2012-02-12
Posts: 6

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

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 ?

Offline

 

#9 2012-02-14 02:15:20 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11483
Website

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

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

Applescript:

tell application "Finder"
   doSomething()
end tell

Applescript:

tell application "Finder" to doSomething()

Last edited by StefanK (2012-02-14 02:17:54 am)


regards

Stefan

Offline

 

#10 2012-02-14 03:50:14 am

mimiba
Member
Registered: 2012-02-12
Posts: 6

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

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 ??

Offline

 
  • Index
  •  » Automator
  •  » How could I return the result (of Applescript) to next workflow ?

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)