Applescript在网站上输入文字

时间:2014-01-09 20:41:37

标签: automation applescript copy-paste paste

set query to text returned of (display dialog "Enter Query" default answer "" buttons {"Input", "Cancel"} default button 1)

open location "http://www.soundcloud.com/"
delay 1
tell application "System Events"
    key code 48
end tell
delay 1
query

所以我正在尝试制作一个苹果:

1)提示用对话框输入数据

2)打开网页

3)按Tab键进入第一个文本框

4)粘贴步骤1中的数据

我已经想出了如何进入第4步,但是当我打印查询变量时,它只会在AppleScript中打印它而不是网页。

2 个答案:

答案 0 :(得分:0)

set query to text returned of (display dialog "Enter Query" default answer "" buttons {"Input", "Cancel"} default button 1)

open location "http://www.soundcloud.com/"
delay 1
tell application "System Events"
    key code 48
    delay 1
    keystroke query
end tell

我需要在命令行中添加击键

答案 1 :(得分:0)

请改为尝试:

set query to text returned of (display dialog "Enter Query" default answer "" buttons {"Input", "Cancel"} default button 1)

tell application "Safari"
    if not (exists document 1) then reopen
    activate
    set URL of document 1 to "http://rna.tbi.univie.ac.at/cgi-bin/RNAfold.cgi"
    delay 3
    do JavaScript "document.getElementsByName('SCREEN')[0].value=" & quoted form of query & "" in document 1
end tell