Page 1 of 1

Quick conversion multiple keys to scancodes

Posted: 24 Oct 2016, 03:59
by SashaChernykh
Briefly

How I can quick convert multiple keys to scancodes?


Detail

For example, I have simple script: Ctrl+A, Ctrl+V.

Code: Select all

Send, {LControl Down}
Send, {a}
Send, {LControl Up}
Send, {LControl Down}
Send, {v}
Send, {LControl Up}
I have 2 keyboard layouts: English and Russian. If I in Russian keyboard layout, this script not work for me. I need click right mouse button in tray → OpenViewKey History and script info → I get scancodes → I change keys:

Code: Select all

Send, {LControl Down}
Send, {sc01E}
Send, {LControl Up}
Send, {LControl Down}
Send, {sc02F}
Send, {LControl Up}
Now my script work in Russian keyboard layout.

But if in my script many keys, I need change keys to scancodes many times.


Extended behavior

I select all keys of my script in my text editor → I run command Convert Keys to Scancodes → all keys converted to scancodes.

Are programs/scripts available, use which I can do the expected behavior?

Thanks.

Re: Quick conversion multiple keys to scancodes

Posted: 24 Oct 2016, 06:54
by Helgef

Re: Quick conversion multiple keys to scancodes

Posted: 24 Oct 2016, 12:01
by SashaChernykh
@Helgef, may you show small example, how use this function for my example code?

Thanks.

Re: Quick conversion multiple keys to scancodes

Posted: 25 Oct 2016, 02:46
by ahcahc
This will replace any single character inside the braces {} to its scancode equivalent.

Code: Select all

F2::	;select text including braces {x} then press F2
cb_old := ClipboardAll
Clipboard :=
send, ^{sc2e}
ClipWait, 1
while pos := regexmatch(Clipboard,"(?<={).(?=})",m, a_index=1?1:pos+strlen(m))
	Clipboard := RegExReplace(Clipboard,"(?<={)" m "(?=})", Format("sc{:x}", GetKeySC(m)), , 1, pos)
send, ^{sc2f}
Clipboard := cb_old
return

Re: Quick conversion multiple keys to scancodes

Posted: 26 Oct 2016, 03:20
by SashaChernykh
ahcahc wrote:This will replace any single character inside the braces {} to its scancode equivalent.

Code: Select all

F2::	;select text including braces {x} then press F2
cb_old := ClipboardAll
Clipboard :=
send, ^{sc2e}
ClipWait, 1
while pos := regexmatch(Clipboard,"(?<={).(?=})",m, a_index=1?1:pos+strlen(m))
	Clipboard := RegExReplace(Clipboard,"(?<={)" m "(?=})", Format("sc{:x}", GetKeySC(m)), , 1, pos)
send, ^{sc2f}
Clipboard := cb_old
return
@ahcahc, thanks, it works!

I'm sorry, I can not accept your answer.

Image