English 中文(简体)
a 补充文字:如何在系统活动方面自动选择节省文件
原标题:applescript: how to automatically choose to save a safari document at a PARTICULAR PATH with system events

我想作一个文字,利用系统活动(共同+)节省聋.文件,我希望文件总是在特定道路上保存。 (我可以习惯于总是在某个方面保存聋 files人档案,但这不是一个有力的解决办法),我能确保系统的活动能在某些方面节省一份文件?

问题回答

Directly from this MacRumors forum post:

tell application "Safari"
    activate
end tell

tell application "System Events"
    tell process "Safari"
        click menu item "Copy" of menu "Edit" of menu bar 1
    end tell
end tell

delay 1

set the_filename to (the clipboard) & ".html"
set the_filepath to "Macintosh HD:Users:Roy:Documents:" & the_filename
set the_shellfilepath to " /Users/Roy/Documents/" & the_filename & ".download "
set the_shellfilepath2 to " /Users/Roy/Documents/" & the_filename & " "

tell application "Safari"
    activate
    save document 1 in the_filepath
end tell

do shell script "mv " & the_shellfilepath & " " & the_shellfilepath2

酌情确定道路(the_shellfilepath)。

3. 改变档案辩证的夹:

try
    try -- this would result in an error when there s no clipboard
        set old to the clipboard
    end try
    -- delay 1 -- for testing
    -- activate application "Safari"
    tell application "System Events"
        keystroke "s" using command down
        keystroke "g" using {shift down, command down}
        delay 0.1
        set the clipboard to "~/Movies/"
        delay 0.1
        keystroke "av" using command down
        delay 0.1
        keystroke return
        delay 0.1
    end tell
    set the clipboard to old
end try

a. 向特定文件夹提供部分编码的URL作为档案名称:

tell application "Safari"
    set x to URL of document 1
    set r to do shell script "echo " & quoted form of x & " | sed  s|/$||;s|:|%3A|g;s|/|%2F|g "
    do shell script "curl " & x & " > " & quoted form of ((system attribute "HOME") & "/Desktop/" & r & ".html")
end tell

a. 向特定文件夹投稿,但手工选择文件名称:

tell application "Safari"
    set x to URL of document 1
    set answer to text returned of (display dialog "" default answer ".html")
    do shell script "curl " & x & " > " & quoted form of ((system attribute "HOME") & "/Desktop/" & answer)
end tell




相关问题
Creating Help Files - Applescript Studio

I would like to know how to generate help files for an applescript studio application I am currently creating. I have tried many different options of creating help, and googled it for quite some time ...

封顶下载和开放式链接

I ve在Angap邮报中设定了一条规则,以操作“Download & Openlink”pple。 我希望这一文字在邮件电文中下载该词,在下载该词之后,该词应开放。

AppleScript to open named terminal window

I have two windows/tabs set up to run in Terminal.app, "syd" and "mel". i.e. in Shell | New Window, "syd" and "mel" are listed. How can I open these terminal configurations with AppleScript?

Hello World Error

I m learning AppleScript and my first program is a Hello World(of course!): display dialog "Hello World" But when I try to run this I got the error: The result of a numeric operation was too ...

User properties/ privileges in AppleScript

I want to write an applescript program that first checks to see if the user has Admin privileges, and if it doesn t then requesting a re-log-in or something. Eventually the script is going to need to ...

Applescript to archive email in Mail.app

I need to write an Applescript for Mail.app that will take all messages in my Inbox and Sent Messages that are older than a certain # of days and move them into respective folders "On My Mac", or ...

热门标签