Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to sleep computer while using TV software ..

Hi.

I don´t know much about applescript but I manage to do a script to sleep my computer after a number of minutes.


I have the following code


display dialog "Minutes to Shut down:" default answer "60"

delay ((the text returned of the result) * 60)

tell application "EyeTV" to quit -- Set AppName to the name of the application you want to quit.

tell application "Finder"

sleep

end tell


At the moment it works and have been using it for a long time, but I need to introduce some code so the script can be interrupted (by pressing esc or other key) without sending the computer to sleep. At the moment, even when I try to abort the script, the computer goes to sleep.


I would appreciate any help.


S

Posted on Nov 22, 2013 6:31 PM

Reply
4 replies

Dec 2, 2013 12:39 PM in response to sevesp

If a dialog is being shown the escape key will also cancel. Another possibility would be to use a keyboard shortcut for the quit menu item in a script application.


AppleScript doesn't really have a built-in way to detect key presses, so other than what has been mentioned you would need to use a third party utility or develop your script in Xcode (in order to access events via Cocoa).

Applescript to sleep computer while using TV software ..

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.