AppleScript and System Events "keystroke" function lead to incorrect casing when using uppercase letters
Originator: | wgray | ||
Number: | rdar://29825727 | Date Originated: | 29-Dec-2016 10:36 AM |
Status: | Closed | Resolved: | No |
Product: | macOS + SDK | Product Version: | macOS Sierra 10.12.2 (16C67) |
Classification: | Serious Bug | Reproducible: | Always |
Area: Something not on this list Summary: This is an "us, too" report for rdar://29182929 where the keystroke function is incorrectly casing of output to uppercase based on uppercase and other sentinel characters. We've also identified a work-around that we haven't seen reported, described in Additional Notes. Steps to Reproduce: 1. Open Script Editor 2. Either open the attached sample script or paste this: tell application "Terminal" activate tell application "System Events" to keystroke "This is a test" end tell 3. Watch the output in Terminal.app Expected Results: The script should properly print each entered character in the correct casing. Actual Results: The casing is different from what was entered and differs with almost every run. Version: macOS Sierra 10.12.2 (16C67) Notes: This is our work-around, forcing an adjustment to shift after using keystroke to emit each character individually: tell application "Terminal" activate tell application "System Events" set outputString to "mmalibu@zetetic.net" set len to length of outputString repeat with i from 1 to len set x to character i of outputString keystroke x key up {shift} end repeat end tell end tell I should note that the problem appears to remain in 10.12.3 Beta 2. Configuration: The output is occasionally correct, but the frequency varies quite a bit. Attachments: 'AdjustKeystroke.scpt' was successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!