AppleScript Abfrage mit Tastatur bedienen...leider kein Focus?

M

mindsuk

Mitglied
Thread Starter
Dabei seit
09.01.2007
Beiträge
60
Reaktionspunkte
0
Hallo,

ich habe ein AppleScript mit EyeTV, das mir am Ende eine Abfrage bringt, ob ich den Rechner Schlafen legen / ausschalten will Ja/Nein.
Da ich mein Mediacenter via iRed2 bediene und hier mit Tastaturkürzel arbeite, möchte ich mit links/rechts den entsprechenden Button auswählen können, also auch mit Nein das "Abschaltescript" abbrechen möchte.

Leider geht das mit dem beigefügten Script aktuell nicht. Kann mir jemand weiterhelfen, wie ich das realisieren kann?

LG

_____________

-- this script reuses modified AppleScript snippets of the following sources:

-- a) Christopher Kampmeier's Blog "Fun with EyeTV and AppleScript" (Script Structure)
-- b) MacUser.de Community Forum, by user oneOeight "EyeTV3 RecordingDone Script zum ausschalten"
-- TST 2012/01


-- RecordingDone-called.scpt
-- copyRecord() : moves recording from local HDD to a shared network drive
-- checkEnergySaving(): switches mac to sleeps or shutdown after EyeTV completes a recording

property ARCHIVE_DIR : "~/Documents/EyeTV\\ Archive"
property NETSHARED_DIR : "/Volumes/video/SharedEyeTV"


on run argv
set recordingID to item 1 of argv
-- manually started converter job?
set posix_recording_path to getPOSIXRecordingPath(recordingID)
if not (posix_recording_path contains "SharedEyeTV") and noExportJobFor(recordingID) then
try
moveRecordToNAS(recordingID)
on error errorText
log "copy record failed: " & errorText
end try
checkEnergySaving()
end if
end run

on checkEnergySaving()
if not eyeTVisBusy() then
-- Quelle für Vorlage: MacUser.de Community Forum, user oneOeight "EyeTV3 RecordingDone Script zum ausschalten"
set ausschalten to my keineAnstehendeAufnahmeIn(180)
set ruhezustand to my keineAnstehendeAufnahmeIn(30)

tell application "EyeTV.app" -- fuer activate und display dialog
if ausschalten then
activate
beep
set antwort to display dialog "TV Aufnahme beendet - Ausschalten?" buttons {"nein", "ja"} default button "ja" giving up after 30
if button returned of antwort = "ja" or button returned of antwort = "" then
log (current date) & "shut down computer"
tell application "Finder" to sleep
end if
else if ruhezustand then
activate
beep
set antwort to display dialog "TV Aufnahme beendet - Ruhezustand?" buttons {"nein", "ja"} default button "ja" giving up after 30
if button returned of antwort = "ja" or button returned of antwort = "" then
log (current date) & "setting computer to sleep"
tell application "System Events" to sleep
end if
end if
end tell
end if
end checkEnergySaving

on noExportJobFor(recordingID)
tell application "EyeTV.app"
return not «class Iexp»
end tell
return true
end noExportJobFor

on moveRecordToNAS(recordingID)
set posix_recording_path to getPOSIXRecordingPath(recordingID)
set myid to recordingID as integer

try
mount volume "smb://192.168.178.100/video" --mount destination file
end try
set cmd to "cp -R \"" & posix_recording_path & "\" \"" & NETSHARED_DIR & "\""
log "running \"" & cmd & "\""
do shell script "" & cmd & ""


tell application "EyeTV.app"
delete «class cRec» id myid
end tell

if not eyeTVisBusy() then
restartEyeTV()
end if
end moveRecordToNAS

on getPOSIXRecordingPath(recordingID)
tell application "EyeTV.app"
set myid to recordingID as integer
set recording_location to URL of «class cRec» id myid as text
set AppleScript's text item delimiters to "."
set recording_path to text items 1 through -3 of recording_location as string
set AppleScript's text item delimiters to ""
set recording_path to POSIX path of recording_path & ".eyetv"
end tell
return recording_path
end getPOSIXRecordingPath


on restartEyeTV()
with timeout of 60 seconds
tell application "EyeTV.app"
quit
end tell
delay 10
tell application "EyeTV.app"
activate
end tell
end timeout
end restartEyeTV

on eyeTVisBusy()
tell application "EyeTV.app"
return «class IRcd» or «class Iexp» or «class ISCr»
end tell
end eyeTVisBusy

-- steht innerhalb der nächsten xx Minuten (zeit) keine Aufnahme an?
-- Quelle für Vorlage: MacUser.de Community Forum, by user oneOeight "EyeTV3 RecordingDone Script zum ausschalten"
on keineAnstehendeAufnahmeIn(zeit)
tell application "EyeTV.app"
try
set limit to zeit * minutes
set ausmachen to true
set vorlauf to («class Prpd» 2) * minutes
set jetzt to current date
repeat with aufnahme in «class Stim» of every «class cPrg»
set diff to aufnahme - jetzt
if diff ≥ vorlauf then set diff to diff - vorlauf
if diff ≥ 0 and diff ≤ limit then set ausmachen to false
end repeat
end try
end tell
return {ausmachen}
end keineAnstehendeAufnahmeIn
 
Zuletzt bearbeitet:
Den Fokus kannst du mit Tab ändern. Vielleicht kannst du in iRed ja dafür eine andere Taste zuweisen, in deinem Skript kannst du da nichts ändern.
 
Zurück
Oben Unten