Search Sparrow 之 Alfred 优化代码

来源:互联网 发布:linux dirname 编辑:程序博客网 时间:2024/05/21 22:24
--- Idea by Runar Dankel with hufeng
--- code by fireshadow52 @ stackoverflow.com
on run argv --- runs the script with arguments from cmd line
if appIsRunning("Sparrow") then
tell application "Sparrow"
tell application "System Events"
key code 120 ---f2按键
end tell
end tell
else
tell application "System Events"
tell application "Sparrow" to activate
key code 120
end tell
end if
tell application "Sparrow" to activate --- activates sparrow
tell application "System Events"
tell process "Sparrow" --- implying Sparrow is already activated
set prevTIDs to AppleScript's text item delimiters --- "saves" last delimiter
key code 3 using {command down, option down} --- send cmd+alt+F to Sparrow invoking search
---set AppleScript's text item delimiters to space --- makes sure the pasted item is correctlyhu formated
keystroke (every text item of argv) as string --- types out every argument that was enter upon run
set AppleScript's text item delimiters to prevTIDs --- restores delimite
---tell application "System Events"
---end tell
end tell
end tell
end run




on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
原创粉丝点击