我被任命为创建必须
的应用程序的任务在网页完成加载时显示"The webpage has finished loading."
对话框
确定当前正在下载的项目数
对于数字1,我尝试过if the URL of the front document is "http://applescript.weebly.com" then
,但即使网页未加载,then
部分也会一直运行!
对于2号,我试过这个......
tell application "Safari" to get every item of window "Downloads"
但是这会返回对每个项的引用,甚至是那些已经下载的内容!
结论:我需要帮助。 :S
答案 0 :(得分:1)
在网页完成加载时显示一个对话框
"The webpage has finished loading."
。
仅使用纯AppleScript无法做到这一点。但是,您可以结合使用AppleScript和javascript ...
tell application "Safari"
repeat until (do JavaScript "document.readyState" in document 1) is "complete"
end repeat
display dialog "The webpage has finished loading."
end tell
警告:如果由于某种原因网页未加载,脚本将永远停留在无限重复循环中。
确定当前正在下载的项目数量。
当您下载文件时,它们暂时被赋予名称扩展名download
,因此AppleScript可以告诉Finder获取具有该扩展名的文件并创建警报/对话框:
set the download_count to 0
set the download_folder to (path to downloads folder) as alias --or wherever the items are being downloaded
tell application "Finder" to set the download_count to the count of (every item of the download_folder whose name extension is "download")
if the download_count is 0 then
display dialog "There are currently no downloads in progress."
else if the download_count is 1 then
display dialog "There is currently one download in progress."
else
display dialog "There are currently " & the download_count & " downloads in progress."
end if
<小时/> P.S。感谢您尊重我的网站!
答案 1 :(得分:0)
我在AppleScript编辑器中编写了以下脚本来打开浏览器,在URL中显示我的ISP,完成登录过程并连接到互联网。工作得很好。我想每隔一小时左右添加或修改它以ping“www.google.com”,如果我的连接已经丢失,可以再次重复下面的过程,这会将我的计算机连接回互联网。
我只是在学习这个剧本写作的东西,并且对它的工作方式没有很好的理解,所以如果有人可以提供帮助,请为我简单地说明。非常感谢。
告诉应用程序“Safari”
activate
tell application "System Events"
open location "https://basrah.uswicom.com/login.php"
delay 1
keystroke return
delay 3
keystroke tab
keystroke (ASCII character 29)
delay 1
delay 1
keystroke tab
delay 1
keystroke "123456789"
delay 1
keystroke return
delay 1
keystroke return
end tell
告诉