8

Finder を表示/非表示にするようにマウス ボタンをプログラムしたいと考えています。次の AppleScript を作成し、マウス ボタンにバインドしました。

tell application "System Events"
    --When this script is run,
    --  the frontmost application will be this script itself
    --Get the name of this script as it is running and hide it,
    --  so that the previous frontmost application is in front again
    set theName to name of the first process whose frontmost is true
    set visible of process theName to false

    set theName to name of the first process whose frontmost is true
end tell

if theName is "Finder" then

    tell application "System Events"
        set visible of process "Finder" to false
    end tell


else

    tell application "Finder"
        activate
    end tell

end if

これは機能しますが、かなり遅いです。実行には約 2 秒かかります。
もっと速くしたい。最初の Tell ブロッ​​クは、システム イベントを使用してスクリプトの名前を取得し、それを非表示にします。スクリプトが開始するに最前面のアプリケーションの名前を取得する簡単で高速な方法はありますか? (つまり、スクリプトがアクティブ化されたときにアクティブだったアプリケーション)

4

1 に答える 1

5

実行時間が遅いのは、applescript をアプリケーションとして保存したためです。これにより、アプリケーションが PPC 専用になるため、Rosetta で実行する必要があります。Application Bundle を選択すると、ユニバーサル アプリケーションが作成されます。

于 2009-07-20T04:31:35.050 に答える