Scripting 文件附件未随applescript一起附加

Scripting 文件附件未随applescript一起附加,scripting,safari,applescript,attachment,Scripting,Safari,Applescript,Attachment,我写了一个小的applescript,在safari中附加文件。如果我手动附加附件,所有事情都会发生,但由于未知原因,即使附件被正确选择和提交,也不会上载 我花了几个小时来解决这个问题,并尝试了不同的变体,但没有成功 下面是附加它们的代码。除了applescript之外,我还使用它来模拟鼠标点击 set posix to "/Users/ea/Desktop/Guru/Deliverables" --set folder path tell application "System Eve

我写了一个小的applescript,在safari中附加文件。如果我手动附加附件,所有事情都会发生,但由于未知原因,即使附件被正确选择和提交,也不会上载

我花了几个小时来解决这个问题,并尝试了不同的变体,但没有成功

下面是附加它们的代码。除了applescript之外,我还使用它来模拟鼠标点击

set posix to "/Users/ea/Desktop/Guru/Deliverables" --set folder path
    tell application "System Events"
        keystroke "g" using {shift down, command down}
        keystroke posix
        delay 1
        keystroke return
        delay 2
        keystroke "a" using {command down}
        delay 5
        do shell script "/usr/local/bin/cliclick m:381,339"
        delay 3
        do shell script "/usr/local/bin/cliclick m:818,590"
        delay 2
        do shell script "/usr/local/bin/cliclick tc:."
        delay 2
    end tell
按预期方式选择的文件

单击“选择”后,不会上载任何内容。 试试这个

tell application "Google Chrome" --Whatever your  using 
activate

set posix to "/Users/ea/Desktop/Guru/Deliverables/private" --are the files in here
tell application "System Events"
    keystroke "g" using {shift down, command down}
    keystroke posix
    delay 1
    keystroke return
    delay 2
    keystroke "a" using {command down}
    delay 5
    key code 36
end tell
end tell

出于好奇,你有没有让它工作过?在safari中附加文件是什么意思?打开文件选择窗口后选择文件是什么意思

我知道这已经很晚了,似乎有人已经回答了你的问题,但你没有回答说它是否有效,所以我创建了一些类似的东西,可能会有所帮助:

to clickClassName(theClassName, elementnum)
    tell application "Safari"
        do JavaScript "document.getElementsByClassName('" & theClassName & "')[" & elementnum & "].click();" in document 1
    end tell
end clickClassName

to getValueFromClass(theclass, num)
    tell application "Safari"
        tell document 1
            set theFirstTableHTML to do JavaScript "\n document.getElementsByClassName('" & theclass & "')[" & num & "].value"
            return theFirstTableHTML
        end tell
    end tell
end getValueFromClass


on run
    choose file with prompt "Which folder would like average file size calculated?"
    open {result}
end run

on open theimage
    --tell application "Finder" to set xx to every file in item 1 of theimage
    --display dialog "Hey! the file's alias is: " & (path of theimage as string)
    --display dialog theimage
    set filepath to POSIX path of theimage

    tell application "Safari" to open location "https://upload.vstanced.com"
    delay 2
    clickClassName("btn btn-big white outline", 0)
    tell application "System Events"
        activate application "Safari"
        delay 0.5
        keystroke "g" using {shift down, command down} --open goto
        set the clipboard to filepath
        keystroke "v" using {command down}
        delay 0.7
        keystroke return -- enter goto text
        delay 0.4
        keystroke return --press enter on file

    end tell
    delay 1
    clickClassName("btn btn-big green", 0)

    set thedirectlink to ""
    repeat 15 times
        set thedirectlink to getValueFromClass("r2", 1)
        delay 1
        if thedirectlink is not equal to "" then
            exit repeat
        end if
    end repeat
    set the clipboard to thedirectlink
    tell application "Safari" to close current tab of window 1

    display notification "Upload complete" with title "VStanced Upload" subtitle thedirectlink sound name "blow"
end open
这是脚本编辑器中的一个小滴,将其以文件格式保存为应用程序,当您将图像拖到它上时,它将打开一个图像托管站点,使用javascript打开文件选择窗口,然后几乎完全按照您的操作进行


在选择并输入文件后,它还会从一个小切换按钮中选择直接链接,将直接链接复制到剪贴板,关闭选项卡,播放声音并显示通知。如果你最终尝试了它,但它不起作用,那么就延长延迟时间。我99%肯定它能做任何事。但是如果safari还没有打开,它可能需要很长时间才能进入页面,这会把一切都搞糟。我还将尝试添加等待页面加载的部分。

我将尝试。我的原始代码有什么问题?只是用你的解决方案替换了我的代码。不幸的是,它没有起作用。网站可能会阻止通过脚本上传附件吗?我使用该脚本上传到fiver让我知道您是否希望我将其作为应用程序捆绑包发送给您还是真的?那太棒了!你需要我做什么?{link}确保文件的位置与脚本中的位置相同