I have an AS application that sets a variable to the contents of a text field, and then types it into another application using keystroke. If there is a quote " in the text field, when the variable is set and re-typed using keystroke, the quote " becomes a lowercase a. Example:
“Hey look over there” is the contents of a text field
set sampletext to contents of the text field
result that is typed is:
aHey look over therea
Any suggestions? Should I be using text variables instead of strings?
Thanks for any advice.
A “straight” quote (ASCII character 34) works fine for me.
I usually set the variable to the contents of the text field as string, could that be the cause of the problem? Should I set it as text? String seems to work well in most situations so I just use it all the time.
Keystroke doesn’t seem to work with some other characters either (e.g.
keystroke "¡â„¢£¢âˆž§¶¢ªº“â‰ ")…
I think the behavior of
keystroke is your problem here.
However, you should avoid the needless coercion. The class of the contents of a text field should already be
Unicode text; You don’t need to coerce it to anything else (unless you have a specific reason for doing so).
Also, note that
string is depreciated as of AppleScript 1.9.2 (
Unicode text is preferred).
text is a synonym for
Well, thank you for the helpful string then.