Quick conversion multiple keys to scancodes

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SashaChernykh
Posts: 32
Joined: 01 Sep 2016, 04:04
Contact:

Quick conversion multiple keys to scancodes

24 Oct 2016, 03:59

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.
SashaChernykh
Posts: 32
Joined: 01 Sep 2016, 04:04
Contact:

Re: Quick conversion multiple keys to scancodes

24 Oct 2016, 12:01

@Helgef, may you show small example, how use this function for my example code?

Thanks.
Last edited by SashaChernykh on 24 Oct 2016, 12:07, edited 1 time in total.
ahcahc
Posts: 110
Joined: 25 Jul 2014, 23:55

Re: Quick conversion multiple keys to scancodes

25 Oct 2016, 02:46

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
SashaChernykh
Posts: 32
Joined: 01 Sep 2016, 04:04
Contact:

Re: Quick conversion multiple keys to scancodes

26 Oct 2016, 03:20

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: wpulford and 410 guests