Forums temporarily locked down! Please read!

Author Topic: Is it possible to use applescripts with encrypted apps?  (Read 4370 times)

steven

  • Newbie
  • **
  • Posts: 2
    • View Profile
Is it possible to use applescripts with encrypted apps?
« on: April 28, 2009, 02:39:09 PM »
Hello, I really like the app, it's great and does something (encrypt mail) that has been missing for years on the mac. However I am wondering if it is possible to allow applescripts to automatically run and access encrypted apps?

I suspect the answer is no but I thought I'd try. I do not currently use the mail.app due to lack of password protection, and to be honest the only reason I want to use it, is because I can use applescript to do things like show the number of unread messages on my desktop/growl, etc. I currently use a couple applescripts for ical as well.

Here is a simple example that displays new messages (which would then be passed to geektool or growl):

Code: [Select]
set newline to ASCII character 10
set finalText to ""
tell application id "com.apple.mail"
set unreadCount to (get unread count of inbox)
if unreadCount > 0 then
set theMessages to (messages of inbox whose read status is false)
repeat with i from 1 to number of items in theMessages
set thisMessage to item i of theMessages
set fromMsg to (sender of thisMessage as string)
set subjMsg to (subject of thisMessage as string)
set finalText to finalText & i & ". " & fromMsg & newline & "      " & subjMsg & newline
end repeat
else
set finalText to "No mail."
end if
end tell
finalText

Obviously, if mail.app is unencrypted or already running via espionage login, it works fine. However, if the script is run with mail.app closed, I get an espionage password prompt to unlock mail.app. This is a problem because the script needs to have access so that it can be automated via launchd. Is there any way you can think of to grant a script permission to execute a protected espionage app?

This also seems to be a problem area for iCal/Mail. What I mean is, in iCal you can set an event to email you upon due time. If mail.app is protected, it breaks that function in iCal unless there is some method of granting ical privileges to execute mail.
« Last Edit: December 31, 1969, 11:00:00 PM by Guest »

greg

  • Administrator
  • Veteran
  • *****
  • Posts: 898
    • View Profile
    • http://www.taoeffect.com
Re: Is it possible to use applescripts with encrypted apps?
« Reply #1 on: April 30, 2009, 01:03:01 AM »
Hi Steven,

The only problem here is if Mail's folder is locked.  If the folder is unlocked, then whether Mail is running or not does not matter (if the "tell application id "com.apple.mail"" launches mail if it's not already running).

To get this to work first make sure that the script is saved as an "Application Bundle":



Then add it to Mail's application associations, and uncheck "Lock on Quit":



Make sure that it's not run upon login by any means.  If you need it to run at login, then set the "Launch at Login" option for the association in Espionage.

This means that if the script is launched and Mail isn't running, you'll be prompted to enter the password for Mail's folder, Espionage will unlock the folder, and only after the folder is unlocked will it actually allow the script to be run.

Note: I haven't tested your script to check to see if it will launch the Mail app automatically, if it doesn't do this then you'll need to write some code to first launch Mail, wait until it fully launches, and then tell it to do stuff.
« Last Edit: December 31, 1969, 11:00:00 PM by Guest »
Follow @espionageapp on twitter for news!

steven

  • Newbie
  • **
  • Posts: 2
    • View Profile
Re: Is it possible to use applescripts with encrypted apps?
« Reply #2 on: May 04, 2009, 04:00:06 PM »
Thank you very much Greg! I must admit I haven't tried this yet but I'll give it a shot and let you know what I think as soon as I have some free time to tinker with this. MY objective is to be able to have my script run automatically via launchd, say every 10min to let me know if I have new email, but I still want to prevent anyone from launching mail.app without entering a password. I don't care if it's not 100% secure, just a basic extra level of password-prompt to prevent a quick "prying eye" from taking a peak at mail.app.
« Last Edit: December 31, 1969, 11:00:00 PM by Guest »

greg

  • Administrator
  • Veteran
  • *****
  • Posts: 898
    • View Profile
    • http://www.taoeffect.com
Re: Is it possible to use applescripts with encrypted apps?
« Reply #3 on: May 04, 2009, 05:32:43 PM »
No problem, but if you want the script to run every 10 minutes then I would make sure that it checks to see if Mail is running before attempting to ask it for anything, otherwise you'll get the password prompt.

Also, if you *really* don't care about someone getting access to your email and only want to prevent say, a sister from seeing what's in there, then you can set Espionage to not use any encryption for Mail's folder, in which case you won't need to setup application associations for it.  The application associations are a method of allowing Espionage to delay the launch of an application while it decrypts (mounts) the application's data.
« Last Edit: December 31, 1969, 11:00:00 PM by Guest »
Follow @espionageapp on twitter for news!