Help using the "keystroke" command
Note: I already found out that "key code 21" types "4", etc, but this doesn't help me since I am trying to type a large list of values with numbers in them.
Macbook, Mac OS X (10.5.8)
Macbook, Mac OS X (10.5.8)
*tell application "TextEdit"*
activate
* if not (document 1 exists) then make new document*
* tell application "System Events"*
* keystroke "12980"*
* end tell*
*end tell*
nick092 wrote:
This may have something to do with the fact that I'm using a laptop keyboard... I believe it may be because AppleScript is trying to press the numbers on my keyboard that are beneath the U, I, O, J, K, L, etc...
set code_list to {"18", "19", "20", "21", "23", "22", "26", "28", "25", "29"}
set numtokeystroke to text returned of (display dialog "Enter a number below..." default answer "")
-- set numtokeystroke to "12980"
tell application "TextEdit"
activate
if not (exists document 1) then
make new document
end if
tell application "System Events"
repeat with i from 1 to the count of numtokeystroke
set codelistitem to item i of numtokeystroke
try
key code (item codelistitem of code_list) as integer
on error
key code (item 10 of code_list) as integer
end try
end repeat
end tell
end tell
Help using the "keystroke" command