Why "keystroke" send this symbols?

Ñ„Ñ„Ñ„:Ñ„Ñ„Ñ„Ñ„Ñ„:Ñ„.Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„:Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„:Ñ„Ñ„Ñ„:Ñ„Ñ„Ñ„Ñ„_Ñ„Ñ„Ñ„Ñ„.Ñ„Ñ„Ñ„
instead of
/Users/a.bcd/Documents/tmp/myfile.txt
into Skype application.

But only when Skype is in Russian keyboard layout.
But if i past clipboard content in Skype manually - all OK (no matter of keyboard layout).

Can i emulate “paste” commmand without “keystroke”?

Hello.

I have never tried to change the keyboard layout by a script, and I suppose it may be hard to do so.

Have you tried something like this?

set utf8 to the clipboard as «class utf8»
set the clipboard to utf8
tell application "Skype" to activate
tell application "System Events"
	tell application process "Skype" -- or whatever
		keystroke "v" using command down
		--keystroke utf8
		-- an alternative
	end tell
end tell

I had to add extra line:
keystroke “v” using command down
keystroke “м” using command down --if kyrillic layout (otherwise didn’t passed clipboard content)

Now it work.

Many thanks!

Hi.

‘keystroke’ can only type characters from the currently active keyboard layout. Any characters in the passed text which aren’t in that layout are rendered as whatever the layout produces for key code 0, which appears to be “Ñ„” in the case of Russian.

Hello.

Luckily a Russian keyboard layout types ascii/utf8 characters when fed ascii/utf8. :slight_smile:

As I am curious, I made some tests.

When I ran this piece of code :


set theText to "/Users/a.bcd/Documents/tmp/myfile.txt"

set the clipboard to theText as «class utf8»
tell application "TextEdit" to activate
delay 0.2
tell application "System Events" to tell process "TextEdit"
	keystroke "м" using {command down}
	keystroke theText
	
end tell

I am surprised by the result :

/Users/a.bcd/Documents/tmp/myfile.txt/Ñ„Ñ„Ñ„Ñ„Ñ„/Ñ„.Ñ„Ñ„Ñ„/Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„/Ñ„Ñ„Ñ„/Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„.Ñ„Ñ„Ñ„

Must I understand that
keystroke “м” using {command down}
is the russian version of
keystroke “v” using {command down] ?

It seems that it’s that because if I remove or disable the instruction
keystroke theText, I get the correct result in the TextEdit document.

For me it’s a huge surprise because I always thought that the basic shortcuts : Copy, Cut, Paste, Save were the same worldwide.

Yvan KOENIG (VALLAURIS, France) mercredi 21 janvier 2015 17:27:05

Hello Yvan.

Well, maybe the keys are laid out differently in Russia?

And maybe the OP used the alternate version, using the string for typing, I’m not sure, I am only glad it worked for him! :slight_smile:

When the layout is set to Russian, keystroke “v” using {command down} does nothing.
Keystroke the string give the “infamous” Ñ„Ñ„Ñ„Ñ„Ñ„/Ñ„.Ñ„Ñ„Ñ„/Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„/Ñ„Ñ„Ñ„/Ñ„Ñ„Ñ„Ñ„Ñ„Ñ„.Ñ„Ñ„Ñ„
even if the string is defined as «class utf8».

Yvan KOENIG (VALLAURIS, France) mercredi 21 janvier 2015 18:47:31

PS :
“м” is on the key labeled “V” on azerty/qwerty keyboards.