PDA

View Full Version : AppleScript help...




phoenixuprising
Nov 17, 2008, 02:43 AM
I'm pretty new to apple script so I'm needing some help. I'm trying to write an apple script that will take another apple script copy it into an textedit document and reformat into a single line unix command.

applescript:


tell application "Terminal"
activate
end tell

tell application "System Events"

keystroke "sudo softwareupdate -i -a"
keystroke return
delay 1
keystroke " <<PASSWORD>> "
keystroke return

end tell

to unix command

osascript -e "tell application \"Terminal\"" -e "activate" -e "end tell" -e "tell application \"System Events\"" -e "keystroke \"sudo softwareupdate -i -a\"" -e "keystroke return" -e "delay 1" -e "keystroke \" <<PASSWORD>> \"" -e "delay 1" -e "keystroke return" -e "end tell"

for that example I manually typed it out.

what I have so far is a script that takes what I have in a current open textedit document, copies it, opens a new document and pastes it.




tell application "TextEdit"
activate
end tell

tell application "System Events"
keystroke "a" using command down
keystroke "c" using command down
keystroke "n" using command down
keystroke "v" using command down
keystroke "a" using command down
key code 126
end tell

I have no idea where to go from there though. Any help would be much appreciated.