Reputation: 436
I recently installed Warcraft3:TFT on my Mac using Wine because the Mac version doen't support Lion. I wrote a script using Applescript to run the terminal command for Wine and then disable my hot corners so I wouldn't have any issues with navigating the screen.
I wrote the script and it runs fine through Applescript (Compile > Run). The real problem comes in when trying save the script as an application. I save it as an application and then try to run the application (named "Warcraft III - The Frozen Throne") and get this error:
Here is the script itself:
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
This is the first time I have actually written in Applescript so there maybe some sort of error in it that I am not seeing. Thanks in advance for any advice or input!
Upvotes: 0
Views: 1271
Reputation: 3413
Your error code has nothing to do directly with your AppleScript. Error –10810 is a Launch Services error code signaling a generic, i.e. unknown error. It seems to get thrown quite often when OS X’ process table runs over. There is a quite thorough background post on the issue at the X Labs, complete with step by step instructions to diagnose (and possibly remedy) the issue.
On an OT note, I notice you use GUI scripting to toggle Hot Corners on or off. This is unnecessary: Lion’s System Events can script these settings via its Expose Preferences Suite, i.e.
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
… which spares you the can of worms that is GUI scripting.
Upvotes: 1