Pages

Sunday, June 16, 2013

Need Help With Apple Script

I am trying to make an apple script that will detect when an application (minecraft) is open and then bring up a dialog that wont go away so that only I.T. can remove it.

 

It's a school project that im working on, we have to figure out a way (through applescript) to help students be more productive, everyone else has no experience with apple script but me. I managed to create this in a couple of minutes but there is a couple glitches and problems i cant solve.

 

here's the script:

 

repeat

     if appIsRunning("Minecraft") then

          display dialog "Gaming is not allowed, Your log of your computer programs running has been emailed to the I.T. department. Please visit the I.T. department immedietly to remove this message" buttons {"Report To I.T."} default button 1 with title "Gaming Alert" with icon stop

     end if

     tell application "Minecraft"

  quit

     end tell

end repeat

on appIsRunning(appName)

     tell application "System Events" to (name of processes) contains appName

end appIsRunning

end

 

it works ok...

exept for the fact it works on every application exept minecraft...

Minecraft just freezes and then the script just says error.

 

Im also trying to design a way that applescript will send an email to the school I.T. desk with the students user name. I have this so far...

 

tell application "Mail"

     set theNewMessage to make new outgoing message with properties {subject:"Gaming Alert [username here]"

  , content:"[username here] has been gaming, he is to report to I.T. by the end of the day", visible:true}

     tell theNewMessage

  make new to recipient at end of to recipients with properties {address:"itdesk@blahblahblah.net"}

  send

     end tell

end tell

 

exept the school uses office 365 mail not inbuilt mail, is there any way to make this work?

 

My key issues are

 

1. how to fix the bug

2. how can i combne the scripts?

3.will this work for other games?

4.Can this work with online email bases

5.any other genreral comments on the scripts.


View the original article here

0 comments:

Post a Comment