Захват AppleEvent в Applescript
Хорошо, Unity3d позволяет вам установить внешний редактор скриптов в настройках приложения. Поэтому я хочу использовать яблочный скрипт для запуска собственного редактора. Этот яблочный скрипт до сих пор работал очень хорошо для меня, но я не смог перейти к номеру строки.
Согласно Unity, "номер строки должен передаваться через параметр в AppleEvent. Он должен иметь тип typeChar и keyAEPosition ('kpos'). Структура, отправляемая через этот параметр, имеет следующую структуру:"
struct TheSelectionRange
{
short unused1; // 0 (not used)
short lineNum; // line to select (<0 to specify range)
long startRange; // start of selection range (if line < 0)
long endRange; // end of selection range (if line < 0)
long unused2; // 0 (not used)
long theDate; // modification date/time
};
"lineNum должен быть заполнен правильной строкой. Другие поля не будут заполнены чем-либо, кроме 0 и -1."
Так почему же я не вижу, что это происходит через мой вклад? как мне запечатлеть это яблочное событие?
Мой сценарий:
on run input
set element to item 1 of input
if (element is in {{}, {""}, ""}) then
return
else
tell application "System Events"
set ProcessList to name of every process
if "iTerm" is in ProcessList then
set iterm_running to true
else
set iterm_running to false
end if
log iterm_running
end tell
tell application "iTerm"
activate
if (count terminal) < 1 then
set term to (make new terminal)
else
set term to current terminal
end if
tell term
set create_session to false
try
do shell script ("/usr/local/bin/vim --servername UNITY --remote-send ''")
set create_session to false
on error errorMessage number errorNumber
set create_session to true
end try
if iterm_running then
if create_session then
launch session "Default Session"
activate current session
tell current session
set name to "Unity"
write text "/usr/local/bin/vim --servername UNITY --remote-silent \"$(echo \"/Volumes/" & input & "\" | tr : /)\""
end tell
else
do shell script ("/usr/local/bin/vim --servername UNITY --remote-silent \"$(echo \"/Volumes/" & input & "\" | tr : /)\"")
end if
else
activate current session
tell current session
set name to "Unity"
write text "/usr/local/bin/vim --servername UNITY --remote-silent \"$(echo \"/Volumes/" & input & "\" | tr : /)\""
end tell
end if
end tell
end tell
end if
return input
end run
1 ответ
Если вы обрабатываете событие open, вы должны увидеть некоторые параметры, включая номер строки:
on open (x,y)
display dialog x
display dialog y
-- use x and y in your own script
end open