Я очень новичок в программировании AppleScript. Это мой код, чтобы открыть приложение в 6 вечера. Я сохранил этот код как приложение, и теперь я хочу открывать это приложение автоматически ежедневно в 6 вечера без какого-либо взаимодействия с пользователем. Я хочу сделать это программно; no cron job, no Automator, без календаря, без настроек пользовательских настроек. Я хочу, чтобы код вызывал его. Является ли это возможным?Как автоматизировать приложение для ежедневного запуска в OSX
set targetTime to "6:00:00 PM"
display dialog targetTime -- wait until we reach the target date/time
repeat while (current date) is less than date targetTime
-- should be 60
end repeat
tell application "Myapp"
activate
end tell
-- get the time in the desired format
on getTimeInHoursAndMinutes()
-- Get the "hour"
set timeStr to time string of (current date)
set Pos to offset of ":" in timeStr
set theHour to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
-- Get the "minute"
set Pos to offset of ":" in timeStr
set theMin to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
--Get "AM or PM"
set Pos to offset of " " in timeStr
set theSfx to characters (Pos + 1) through end of timeStr as string
return (**strong text**theHour & ":" & theMin & " " & theSfx) as string
end getTimeInHoursAndMinutes
Да, хороший ответ. Мое голосование :-) –
@regulus: действительно, это очень хороший и простой способ сделать это. мой голос :) – vivek