Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Scripting Keystroke Issue

Here is my script (sending via ARD): one simple error that I cannot determine.


# Script to create Terminal shortcuts in the bash profile; shortcut to show files is showFiles and to then again hideFiles. Login as an admin, set SP to that accounts password.


# Change value of SP to your logged in account password

SP=<password>


# Open a terminal window (Grass.terminal)


open /Applications/Utilities/Terminal.app/Contents/Resources/Initial\ Settings/Grass.terminal


osascript <<EOF

tell application "System Events"

delay 1

keystroke "sudo nano ~/.bash_profile"

keystroke return

delay 3

keystroke "$SP"

keystroke return

delay 5

keystroke "alias showFiles='defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder /System/Library/CoreServices/Finder.app'"

delay 2

keystroke return

keystroke "alias hideFiles='defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder /System/Library/CoreServices/Finder.app'"

delay 2

keystroke "O" using control down # Ctrl-O <^O>

delay 5

keystroke return

keystroke "X" using control down # Ctrl-X <^X>

delay 5

keystroke "source ~/.bash_profile"

keystroke return

delay 5

end tell

EOF


My error is at "keystroke "O" using control down # Ctrl-O <^O>," just get a chime error. Same goes for "keystroke "X" using control down."

Has it changed for 10.9.5 and 10.10? Do you see something wrong with those lines?

MacBook Pro (Retina, 15-inch, Late 2013), OS X Mavericks (10.9.2)

Posted on Apr 7, 2015 11:21 AM

Reply
1 reply

Scripting Keystroke Issue

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.