samedi 20 mars 2021

Applescript at random times during day

I wish i could be of more help.. So new i have been in circles. it runs fine in the script editor but when launching.. i get nothing or a window with the script to edit.

I need to be prompted about 8 times a day at ramdom times to write in a journal. but only during waking hours..

can someone suggest a edit to the script or help in launching. OSAscrpts just sits there and wants me to keep pushing the play button. Yes, the random numbers are very low... for testing..

thanks.

--
--  Created by: Maddy
--  Created on: 2021-03-15
--
--  Copyright © 2021 MH Solutions & Consulting, All Rights Reserved
--

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set recipientName to "Maddy"
set recipientAddress to "xxxxxxxxx@icloud.com"
set theSubject to "Flow Journal"
set theContent to "Time hun, take the time now and go do it,, will take 2 mins."
set i to 3
repeat until i = 0
    tell application "Mail"
        repeat loopCount times
            ##Create the message
        end repeat
        set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
        
        ##Set a recipient
        tell theMessage
            make new to recipient with properties {name:recipientName, address:recipientAddress}
            
            ##Send the Message
            send
        end tell
        set d to random number from 90 to 180
        with timeout of 3 seconds -- don't recall how long your script will wait; this makes sure it's long enough.
            do shell script "sleep " & d -- note the space after sleep.
        end timeout
        set i to i - 1
    end tell
end repeat



Aucun commentaire:

Enregistrer un commentaire