user5726736
user5726736

Reputation: 81

The keystroke command in applescript can't identify case

tell application "iTerm" to activate
delay 0.1
tell application "System Events" to tell process "iTerm"
   keystroke "Lsj!"
end tell

I want know how can i get the right way to enter some character. keystroke command can't identify case.

Upvotes: 1

Views: 310

Answers (3)

macscripter
macscripter

Reputation: 47

That should work

tell application "iTerm" to activate
delay 0.1
tell application "System Events" to tell process "iTerm"
key code 37 using {shift down}
key code 1
key code 38
end tell

Upvotes: 0

pipwerks
pipwerks

Reputation: 4581

wch1zpink's answer should work.

You can also write out the letters individually if needed

    keystroke "l" using {shift down} -- uppercase
    keystroke "sj!" -- lowercase

Upvotes: 1

wch1zpink
wch1zpink

Reputation: 3142

This should work

set the clipboard to "Lsj!" as text
tell application "iTerm" to activate
delay 0.1
tell application "System Events" to tell process "iTerm"
    keystroke (the clipboard)
end tell

Upvotes: 1

Related Questions