Я хочу запрограммировать кнопку мыши, чтобы показать / скрыть 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 использует системные события, чтобы получить имя скрипта и скрыть его. Есть ли более простой / быстрый способ получить имя самого переднего приложения до запуска скрипта? (то есть приложение, которое было активным при активации скрипта)