weixin_33737134 2016-02-18 20:48 采纳率: 0%
浏览 109

Applescript Web表单

I am trying to make an applescript that submit a form on mxtoolbox.com that uses AJAX at this link:

http://mxtoolbox.com/EmailHeaders.aspx

tell application "Safari"
    activate
    tell (make new document) to set URL to "http://mxtoolbox.com/EmailHeaders.aspx"
    delay 10
    tell application "System Events"
-- Copies text from variable headerText to clipboard and paste. Faster than keystroke headerText
        set the clipboard to headerText
        keystroke "v" using command down

    end tell
end tell

Any ideas?

A suggestion was the following but it still did not work:

tell application "Safari"
    activate
    tell (make new document) to set URL to "http://mxtoolbox.com/EmailHeaders.aspx"
    delay 10
    tell application "System Events"
        set the clipboard to headerText
        keystroke "v" using command down
        tell application "Safari"
            do JavaScript ("
document.getElementById('ctl00_ContentPlaceHolder1_txtToolInput').value='" & headerText as text) & "';
document.getElementById('ctl00_ContentPlaceHolder1_btnAction').click();
" in document 1
        end tell
    end tell
end tell
  • 写回答

1条回答 默认 最新

  • weixin_33713503 2016-02-19 09:07
    关注

    You could do this with JavaScript:

    set headerText to "test"
    
    tell application "Safari"
        activate
        tell (make new document) to set URL to "http://mxtoolbox.com/EmailHeaders.aspx"
        delay 5
    
        do JavaScript "
        document.getElementById('ctl00_ContentPlaceHolder1_txtToolInput').value=" & quoted form of headerText & ";
        document.getElementById('ctl00_ContentPlaceHolder1_btnAction').click()" in document 1
    end tell
    
    评论

报告相同问题?