Applescript будет работать как скрипт, но не как приложение - PullRequest
0 голосов
/ 27 февраля 2012

Я недавно установил Warcraft3: TFT на мой Mac, используя Wine, потому что версия Mac не поддерживает Lion.Я написал скрипт, используя Applescript, чтобы запустить терминальную команду для Wine, а затем отключил мои горячие углы, чтобы у меня не возникало проблем с перемещением по экрану.

Я написал скрипт, и он нормально работает через Applescript (Compile> Беги).Настоящая проблема возникает при попытке сохранить скрипт как приложение.Я сохраняю его как приложение, а затем пытаюсь запустить приложение (названное «Warcraft III - The Frozen Throne») и получаю эту ошибку:

error message on script app execution

Вот сам скрипт:

set settings1 to {"-", "Desktop", "Start Screen Saver", "Mission Control"}
set settings2 to {"-", "-", "-", "-"}

tell application "Terminal"
     do script "/opt/local/bin/wine ~/.wine/drive_c/Program\\ Files/Warcraft\\ III/war3.exe"
end tell

tell application "System Preferences"
     reveal pane id "com.apple.preference.expose"
     activate
     tell application "System Events"
     tell window "Mission Control" of process "System Preferences"
        click button "Hot Corners…"
        tell sheet 1
            tell group 1
                set theSettings to settings2
                set functionKeys to false
                repeat with k from 1 to 4
                    set theValue to item k of theSettings
                    tell pop up button k
                        if value is not theValue then
                            click
                            click menu item theValue of menu 1
                        end if
                    end tell
                end repeat
            end tell
            click button "OK"
        end tell
    end tell
end tell
quit
end tell

display alert "Done playing?" buttons {"Yes"}
set response to button returned of the result
if response is "Yes" then
--Start return to normal settings
tell application "System Preferences"
    reveal pane id "com.apple.preference.expose"
    activate
    tell application "System Events"
        tell window "Mission Control" of process "System Preferences"
            click button "Hot Corners…"
            tell sheet 1
                tell group 1
                    set theSettings to settings1
                    set functionKeys to true
                    repeat with k from 1 to 4
                        set theValue to item k of theSettings
                        tell pop up button k
                            if value is not theValue then
                                click
                                click menu item theValue of menu 1
                            end if
                        end tell
                    end repeat
                end tell
                click button "OK"
            end tell
        end tell
    end tell
    quit
end tell
--End return to normal settings

--quit X11 and terminal
tell application "X11"
    quit
end tell
tell application "Terminal"
    quit
end tell
end if

Это первый раз, когда я действительно написал в Applescript, так что, возможно, в нем есть какая-то ошибка, которую я не вижу.Заранее спасибо за любой совет или вклад!

1 Ответ

1 голос
/ 28 февраля 2012

Ваш код ошибки не имеет ничего общего с вашим AppleScript. Ошибка -10810 - это код ошибки Launch Services, сигнализирующий об общей, то есть неизвестной ошибке. Кажется, что это происходит довольно часто, когда таблица процессов OS X переходит. В X Labs имеется довольно подробное справочное сообщение по этой проблеме, содержащее пошаговые инструкции по диагностике (и, возможно, устранению) проблемы.

В заметке OT я заметил, что вы используете сценарии GUI для включения или выключения Hot Corners. В этом нет необходимости: Системные события Lion могут записывать эти параметры в свой Набор настроек Preferences , т.е.

property hotCornerSettings : {}

to disableHotCorners()
    set hotCorners to {}
    tell application "System Events"
        tell expose preferences
            set end of hotCorners to a reference to bottom left screen corner
            set end of hotCorners to a reference to top left screen corner
            set end of hotCorners to a reference to top right screen corner
            set end of hotCorners to a reference to bottom right screen corner
            repeat with hotCorner in hotCorners
                set hotCornerProps to properties of hotCorner
                set end of hotCornerSettings to {hotCorner, {activity:activity of hotCornerProps, modifiers:modifiers of hotCornerProps}}
                set properties of hotCorner to {activity:none, modifiers:{}}
            end repeat
        end tell
    end tell
end disableHotCorners

to restoreHotCorners()
    tell application "System Events"
        tell expose preferences
            repeat with settings in hotCornerSettings
                set properties of item 1 of settings to item 2 of settings
            end repeat
        end tell
    end tell
end restoreHotCorners

… который избавляет вас от червей, которые являются сценариями GUI.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...