如何在 AppleScript 中发送点
How to send dot in AppleScript
我想在 Chrome 中使用 AppleScript 上传文件。文件路径包含点 (.),但此脚本无法将点发送到 'Go to the folder:'。
on run argv
tell application "System Events"
tell application "Google Chrome" to activate
delay 2
log argv
keystroke "g" using {command down, shift down}
delay 1
keystroke item 1 of argv
end tell
end run
我是运行这个命令的脚本:
nsadmins-Mac:util nsadmin$ osascript macUploadChrome.scpt "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py"
此文本出现在 运行 此脚本之后的 "Go to the folder" 字段中:
/System/Library/Frameworks/Pythonframework/Versions//lib/python/socketpy
这很奇怪,但是如果您尝试使用 copy/paste 会怎样:
set the clipboard to (item 1 of argv as string)
keystroke "g" using {command down, shift down}
delay 1
keystroke "v" using {command down}
为什么Chrome?老实说,我对 Safari 从来没有任何问题。无论如何,
--set filepath to POSIX path of theimage
--^^set filepath to the desired file path^^
delay 2
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
也许文件路径太长了。不过我对此表示怀疑。尝试使用它,如果它不适用于 Chrome,请尝试使用 Safari 看看是否是问题所在。当 "file choosing window" 已经打开时,这意味着 运行,但我写的完整脚本有点更广泛,如果你想看它,请告诉我。
我想在 Chrome 中使用 AppleScript 上传文件。文件路径包含点 (.),但此脚本无法将点发送到 'Go to the folder:'。
on run argv
tell application "System Events"
tell application "Google Chrome" to activate
delay 2
log argv
keystroke "g" using {command down, shift down}
delay 1
keystroke item 1 of argv
end tell
end run
我是运行这个命令的脚本:
nsadmins-Mac:util nsadmin$ osascript macUploadChrome.scpt "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py"
此文本出现在 运行 此脚本之后的 "Go to the folder" 字段中:
/System/Library/Frameworks/Pythonframework/Versions//lib/python/socketpy
这很奇怪,但是如果您尝试使用 copy/paste 会怎样:
set the clipboard to (item 1 of argv as string)
keystroke "g" using {command down, shift down}
delay 1
keystroke "v" using {command down}
为什么Chrome?老实说,我对 Safari 从来没有任何问题。无论如何,
--set filepath to POSIX path of theimage
--^^set filepath to the desired file path^^
delay 2
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
也许文件路径太长了。不过我对此表示怀疑。尝试使用它,如果它不适用于 Chrome,请尝试使用 Safari 看看是否是问题所在。当 "file choosing window" 已经打开时,这意味着 运行,但我写的完整脚本有点更广泛,如果你想看它,请告诉我。