0

アプリにフォーカスして「cmd + 1」をクリックする簡単なapplescriptを書いています。

これは私が書いたものです:

tell application "System Events"
    tell application process "appname"
        --Lobby focus
        activate
        keystroke "1" using command down
    end tell
end tell

しかし、動作する代わりに、ビープ音が 1 回鳴り、アプリケーションはフォーカスさえしません。

どうすればこれを解決できますか?

4

1 に答える 1

1

プロセスにアクティブ化を指示することはできません。次のように変更しset frontmost to trueます。

tell application "System Events"
    set frontmost of process "Finder" to true
    keystroke "1" using command down
end tell

または、アプリケーションにアクティベートを指示します:

activate application "Finder"
tell application "System Events"
    keystroke "1" using command down
end tell

アプリケーションで開いているウィンドウがない場合はreopen、新しいデフォルト ウィンドウを開きます。

tell application "Finder"
    reopen
    activate
end tell
tell application "System Events"
    keystroke "1" using command down
end tell
于 2012-10-22T11:39:50.397 に答える