Hello:
I am new to AppleScript, and after some research and loads of attempts, I have finally decided to post to the experts!
I have been trying to setup a Script that will do the following:
1.- Open a website, and save it as a PDF
– code used:
tell application “Safari”
activate
open location “http://mncomacapp01/medpda/tools/whatsup.py”
delay 4
tell application “System Events” to keystroke “p” using {command down}
delay 1
end tell
tell application “System Events” to keystroke “p” using {command down}
delay 1
set thePath to “:Users:username:Desktop:Folde1:Folde2:Folder3:”
set theDate to do shell script “date ‘+%m-%d-20%y-%H%Mhrs’”
tell application “System Events”
tell window 1 to thePath
keystroke theDate as text
delay 0.5
– key code 36
end tell
– Now, so far this creates the PDF file I will need to attach, but I have battled with the following part in both sides, how can I interact with the save window to ensure that it goes to a specific path?
– ** the next part of the code is the one which creates the message…
Here is the only way I have managed to get the script to navigate to the actual file, I am sure there is a much easer cleaner and elegant way to do this!
tell application “Microsoft Entourage”
activate
delay 1
set theDate to do shell script “date ‘+%m-%d-20%y-%H%Mhrs’”
set theSubject to “What’s up report for " & theDate as text
set theBody to “What’s up report for today”
set StartFolderSelection to “:Users:username:Desktop:Folder1:Folder2:Folder3:”
→ set theAttachment to choose file StartFolderSelection
set theRecipients to {{address:{display name:“John Doe”, address:"jdoe@server.com”}, recipient type:to recipient}, {address:{display name:“Jane Doe”, address:"janedoe@server2.com"}, recipient type:bcc recipient}}
set theMessage to make new outgoing message with properties {recipient:theRecipients, subject:theSubject, content:theBody}
open theMessage
delay 3
tell application "System Events" to keystroke "e" using {command down}
delay 2
--> Go up
tell application "System Events" to key code 48
delay 0.2
tell application "System Events" to key code 48
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
tell application "System Events" to key code 126
delay 0.2
--> Go down
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 124
delay 0.2
tell application "System Events" to key code 48
delay 1
-->
tell application "System Events" to key code 125
delay 0.3
tell application "System Events" to key code 125
delay 0.3
tell application "System Events" to keystroke "Folder1"
delay 0.2
delay 1
tell application "System Events" to key code 124
delay 1
tell application "System Events" to keystroke "Folder2"
delay 0.3
tell application "System Events" to key code 124
delay 1
tell application "System Events" to keystroke "Folder3"
delay 0.5
tell application "System Events" to key code 124
delay 1
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 125
delay 0.2
tell application "System Events" to key code 36
delay 1
tell application "System Events" to key code 36 using {command down}
end tell
– Please help me understand how to work with the interacting windows such as the one that pops up on save and on Attach,
An other thing that I have noticed is, if I have the script setup to run at a certain time, and the machine is on stand by, the Screen saver Password window will take the “keystroke” commands and type them there instead of the desired window.
thanks!!
HT
Model: MacBook Pro 15in
AppleScript: 2.1.2
Browser: Safari 534.50
Operating System: Mac OS X (10.6)