我正在使用Automator appleScript将新图片上传到我的Instagram。
将新文件添加到文件夹updates
on adding folder items to myFolder after receiving FileList
repeat with aFile in FileList
activate application "Uploader HD for Instagram"
delay 0.5
delay 0.5
tell application "System Events"
tell process "Uploader HD for Instagram"
click menu item "Open..." of menu 1 of menu bar item "File" of menu bar 1
end tell
end tell
delay 1
tell application "System Events"
keystroke "G" using {command down, shift down}
delay 0.5
keystroke myFolder
delay 1
delay 1
keystroke return
keystroke (ASCII character 31)
delay 1
keystroke return
delay 1
keystroke tab
end tell
tell application "System Events"
tell process "Uploader HD for Instagram"
click button "Post" of window "Uploader HD for Instagram"
delay 1
tell application "Uploader HD for Instagram"
quit
end tell
end tell
end tell
try
tell application "Finder"
delete (every item of folder myFolder whose name ends with ".jpg")
end tell
on error
display dialog ("Error. Couldn't Move the File") buttons {"OK"}
end try
end repeat
end adding folder items to
我正在使用var
myFolder
使用“转到文件夹”搜索文件
var myFolder
有效,但只提供了文件夹的路径,我需要文件夹的路径+ File.ext
非常感谢任何帮助/
感谢/.
答案 0 :(得分:0)
如果我很清楚你想要的是什么,你想用Uploader HD应用程序打开每个刚加入特定文件夹的文件。
如果这是正确的,那么只需使用文件夹操作。每次将新文件添加到文件夹时,系统将触发脚本,仅作为参数提供刚添加的文件(而不是之前已存储在该文件夹中的文件!)。对于添加的每个文件,您只需要让HD上传器打开它。
您必须首先将脚本命名为“更新”文件夹:
将脚本复制/粘贴到ScriptEditor中并将其保存在〜library / Scripts / Folder Action Scripts中
右键单击您的文件夹(更新“)并添加此文件夹操作脚本。
on adding folder items to myFolder after receiving FileList
repeat with aFile in FileList
tell application "Uploader HD for Instagram" to open aFile
end repeat
end adding folder items to
我无法使用Instagram上传器进行测试(我没有)。可能会发生一些应用程序没有回答“打开”命令。如果是这种情况,您可能需要用其他方法替换“tell application ... open aFile”这一行来打开它。您可以使用包含添加文件的完整路径的变量aFile。 aFile是别名类型,(aFile as string)是您可以在goto对话框中使用的字符串。
答案 1 :(得分:0)
这是最终的工作代码,我遗漏的是POSIX
使用var
定义的myFilePath
set
包含path
的完整file
on adding folder items to myFolder after receiving FileList
try
repeat with i from 1 to number of items in FileList
repeat with aFile in FileList
activate application "Uploader HD for Instagram"
delay 0.5
delay 0.5
tell application "System Events"
tell process "Uploader HD for Instagram"
click menu item "Open..." of menu 1 of menu bar item "File" of menu bar 1
end tell
end tell
delay 0.5
set myFilePath to POSIX path of item i of FileList
tell application "System Events"
keystroke "G" using {command down, shift down}
delay 0.5
keystroke myFilePath
delay 0.5
keystroke return
delay 0.5
keystroke return
delay 0.5
keystroke tab
keystroke "#Instagood #Instagram #Luxury #Babe #Model #Follow @CindyJordanLove"
end tell
tell application "System Events"
tell process "Uploader HD for Instagram"
click button "Post" of window "Uploader HD for Instagram"
delay 1
tell application "Uploader HD for Instagram"
quit
end tell
end tell
end tell
try
tell application "Finder"
delete (every item of folder myFolder whose name ends with ".jpg")
end tell
on error
display dialog ("Error. Couldn't Move the File") buttons {"OK"}
end try
end repeat
end repeat
end try
end adding folder items to