image
image

|


Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old June 11th, 2007, 01:21 PM
Gambuchi's Avatar
Purveyor of Thought...
 
Join Date: Nov 2003
Location: Oregon
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Gambuchi is on a distinguished road
Apple mail initiated AppleScript.

I am trying to impliment a applescript I got from one of the forums to put my computer to sleep using the arrival of a 'certain' email to trigger an applescript... here is the information you might need to help me figure why it refuses to work.:

The email arrives in the inbox but will not execute the applescript but if I run the applescript outside of mail, it works perfectly. I am lost. If you can help, please do so
Attached Images
File Type: jpg Picture 1.jpg (26.4 KB, 6 views)
File Type: jpg Picture 2.jpg (11.0 KB, 7 views)
File Type: jpg Picture 3.jpg (44.4 KB, 5 views)
File Type: jpg Picture 4.jpg (31.4 KB, 7 views)
__________________
___________________________
••• "It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err."

Mahatma Gandhi •••
Reply With Quote
  #2  
Old June 19th, 2007, 12:43 PM
Head Dish Washer
 
Join Date: Dec 2006
Location: Canada
Posts: 509
Thanks: 1
Thanked 2 Times in 2 Posts
supanatral is on a distinguished road
I'm not exactly sure as to how to get it to work, but I know why it's not working. Your Apple script is only programed to show a dialog box to ask the user whether they want the computer to be put to sleep or not. Nothing in that script tells it to look for whether there is any mail present.

It's not the script that is causing a problem. The problem that the script isn't being launched when you get that mail.
__________________
3G iPhone on Rogers network
20" iMac 1.83GHz Intel Core Duo w/1.5GB of ram
15" Macbook Pro 2.2GHz Intel Core 2 Duo w/2GB of ram

-
In a world without walls and fences, who needs Windows and Gates?
Reply With Quote
  #3  
Old June 19th, 2007, 01:16 PM
bobw's Avatar
The Late: SuperMacMod
 
Join Date: Mar 2001
Location: Phila,PA
Posts: 8,835
Thanks: 0
Thanked 1 Time in 1 Post
bobw has a spectacular aura aboutbobw has a spectacular aura about
Try this;

tell application "System Events" to sleep
__________________

Reply With Quote
  #4  
Old June 19th, 2007, 01:36 PM
Head Dish Washer
 
Join Date: Dec 2006
Location: Canada
Posts: 509
Thanks: 1
Thanked 2 Times in 2 Posts
supanatral is on a distinguished road
Quote:
Originally Posted by bobw View Post
Try this;

tell application "System Events" to sleep
Bobw: What is a good website that you would suggest for someone that wants to learn how to write an applescripts?
__________________
3G iPhone on Rogers network
20" iMac 1.83GHz Intel Core Duo w/1.5GB of ram
15" Macbook Pro 2.2GHz Intel Core 2 Duo w/2GB of ram

-
In a world without walls and fences, who needs Windows and Gates?
Reply With Quote
  #5  
Old June 19th, 2007, 01:44 PM
bobw's Avatar
The Late: SuperMacMod
 
Join Date: Mar 2001
Location: Phila,PA
Posts: 8,835
Thanks: 0
Thanked 1 Time in 1 Post
bobw has a spectacular aura aboutbobw has a spectacular aura about
Take a look Here and Here
__________________

Reply With Quote
  #6  
Old June 20th, 2007, 11:49 AM
Gambuchi's Avatar
Purveyor of Thought...
 
Join Date: Nov 2003
Location: Oregon
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Gambuchi is on a distinguished road
Quote:
Originally Posted by ;1412030
I'm not exactly sure as to how to get it to work, but I know why it's not working. Your Apple script is only programed to show a dialog box to ask the user whether they want the computer to be put to sleep or not. Nothing in that script tells it to look for whether there is any mail present.

It's not the script that is causing a problem. The problem that the script isn't being launched when you get that mail.
Actually, supanatral, the mail program does call the script and the script does launch... the problem is that it hangs just before the "display dialect" line and goes no further or possibly drops out at that point. I've placed some 'beep' commands in it to determine how far it gets so I know it does at least start to work. Odd thing is that if I run the script from the desktop, it works perfectly. I cannot, for the life of me, figure out why it stops right at the 'display dialog' line of code. Perhaps you have an answer for me... also there is a line there that tells the system to 'sleep' and that works from desktop running also. I am curious is perhaps an earlier version of 'Mail' would run it properly and if that is the case then the problem could be related to a programming change in subsequent versions of Mail.
__________________
___________________________
••• "It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err."

Mahatma Gandhi •••
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 10:11 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.