2014-03-05 12 views
0

基本上,我的目標是編寫一個鍵盤命令(選項-s)來激活Stickies並創建一個新音符。現在我有一個阿爾弗雷德2生成自動化這熱鍵鏈接到下面的腳本:Alfred 2中的延遲,使用Automator和Apple腳本打開「Stickies」並創建一個新音符

on alfred_script(q) 
    tell application "Stickies" to activate 
    delay .2 
    tell application "Stickies" to activate 
    delay .01 
    tell application "System Events" 
     keystroke "n" using command down 
    end tell 
end alfred_script 

兩個激活命令是我試圖解決它打開應用程序中的錯誤,但不把它前面。當應用程序在後臺打開時,它可以無縫工作,但速度很慢,並且在應用程序尚未運行時會創建屏幕閃光。延遲不是來自應用程序本身,因爲我可以打開應用程序並儘可能快地執行命令-n,並且它始終有效。

(順便說一句,如果你對我怎麼會隱藏所有其他音符只顯示新的想法,那將是真棒!)

回答

0

你可以試試這個替代方法,可能有不同的效果。

tell application "System Events" 
    tell process "Stickies" 
     set frontmost to true 
     keystroke "n" using command down 
     keystroke "Hello World" & linefeed & "I'm a new note!" 
    end tell 
end tell 

隱藏所有其他的筆記,我會說開始一個新的問題。

1

試試這個:

launch application "Stickies" 
tell application "System Events" to tell process "Stickies" 
    click menu item "New Note" of menu "File" of menu bar 1 
    set frontmost to true 
end tell 

如果運行按選項-S腳本,可能沒有足夠的時間keystroke "n" using command down之前釋放的選項。

或者這不會提高窗戶的其他注意事項:

launch application "Stickies" 
tell application "System Events" to tell process "Stickies" 
    click menu item "New Note" of menu "File" of menu bar 1 
end tell 
do shell script "open -a Stickies" 

activate app "Appname"set frontmost of "Appname" to true提高所有窗口,但do shell script "open -a Appname"提出只有一個窗口。

熱鍵也都默認在阿爾弗雷德在短暫的延遲,但是你可以通過改變觸發行爲,減少碳排放量