Simulating Ctrl + Shift + Unicode on Windows

Get help with using AutoHotkey and its commands and hotkeys
aleskva
Posts: 5
Joined: 08 May 2017, 10:06

Simulating Ctrl + Shift + Unicode on Windows

08 May 2017, 10:27

On Windows I miss the Linux functionality, that any existing character could be inserted by pressing Ctrl + Shift + u1234, where "1234" is a Unicode code of that character.

Some of the characters could be added by Alt codes (Alt + code on numeric keyboard), but the range of characters insertable by Alt codes is too limited. Unfortunately I haven't got a numeric keyboard and I'm really used to use Unicode character codes.

The only way how to use Unicode codes on Windows I've already found is in Microsoft Office, which comes with a built-in functionality 1234 + Alt + X (where 1234 stands for Unicode character code). But I want to use Unicode everywhere, not only in MS Office.

I've got a recommendation to AHK, which looks it could help me with my issue. I learned some basics of AHK and I also can make a huge (almost 1 GB) list of all Unicode characters and their codes, but I still haven't figured out yet, how to make this together into working script. Could somebody just point me at some script parts, which should I use to achieve my aim? Or just give me a push, where in tutorials I should search? or is there some already existing working script I could use?
Last edited by aleskva on 08 May 2017, 12:42, edited 1 time in total.
Helgef
Posts: 4464
Joined: 17 Jul 2016, 01:02
Contact:

Re: Simulating Alt + Shift + Unicode on Windows

08 May 2017, 10:38

Nice idea, maybe something like this.

Code: Select all

^+u::
	Input,n, L4,{esc}{space}{enter}
	n:="0x" . n			; Edit
	if n is integer	
		Send,% "{U+" n "}"
return
Cheers.

edit:
Integer check.
If you want to see what you are typing,

Code: Select all

^+u::
	Input,n, V L4,{esc}{space}{enter}
	n:="0x" . n
	if n is integer
		SendInput,% "{bs 4}{U+" n "}"
return
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Simulating Alt + Shift + Unicode on Windows

08 May 2017, 10:45

Maybe you could make a hotkey that allows to type a number and then send the Unicode character.

Code: Select all

^+u::
	Input, num, L4,{Space}{Enter}
	SetFormat, IntegerFast, Hex
	Send {U+%num%}
Return
Looks like I'm a little slow.

Edit:
I forgot the 'u' part of the hotkey, Oops.
Last edited by Nightwolf85 on 08 May 2017, 11:16, edited 1 time in total.
aleskva
Posts: 5
Joined: 08 May 2017, 10:06

Re: Simulating Alt + Shift + Unicode on Windows

08 May 2017, 11:12

Wow, pretty much more simple than I thought. Both solutions work almost fine, just two catches there.

On Linux I press Ctrl + Shift, hold this combination and then I type "u1234". "u1234" are all visible. I can type 1-5 letters (but in 99% I use exactly 4 letters). After I release Ctrl + Shift, the code after "u" is processed to Unicode character (maybe I didn't write it correctly in my first post).

I use the Czech keyboard layout, which has 1-9 and 0 on top of keyboard to baehave as numbers only with Shift
Last edited by aleskva on 08 May 2017, 14:52, edited 1 time in total.
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Simulating Alt + Shift + Unicode on Windows

08 May 2017, 11:15

aleskva wrote:Wow, pretty much more simple than I thought. Both solutions work almost fine, just one last catch.

On Linux I press Ctrl + Shift, hold this combination and then I type "u1234". "u1234" are all visible. I can type 1-5 letters (but in 99% I use exactly 4 letters). After I release Ctrl + Shift, the code after "u" is processed to Unicode character (maybe I didn't write it correctly in my first post).
In my version you didn't need the u at all, my bad. (I've since edited in the 'u' so the keypress is the same as Helgef's)

In Helgef's version you would just press Ctrl+Shift+u, no need to hold anything, then when you press 4 numbers it would finish the input and send the unicode automatically. Or if you did less than 4 numbers you would need to press Space, Esc, Enter to finish the input and send the unicode.

Hope that helps understand what is happening.
Helgef
Posts: 4464
Joined: 17 Jul 2016, 01:02
Contact:

Re: Simulating Alt + Shift + Unicode on Windows

08 May 2017, 11:39

I'm sure I made some mistake here, let me know. :crazy:

Code: Select all

^+u::
	SendInput,u
	Hotkey,shift up,sf24,on
	Hotkey,ctrl up,sf24,on
	holding:=1
	n:=""
	while holding {
		Send,{Ctrl up}{Ctrl shift}
		Input,p, V L1,{esc}{space}{enter}{F24}
		n.=p
	}
	Hotkey,shift up,sf24,off
	Hotkey,ctrl up,sf24,off
	b:="0x" . n
	if b is integer
		SendInput,% "{bs " strlen(n)+1 "}{U+" n "}"
return
esc::exitapp
sf24:
	holding:=0
	Send,{F24}
return
Helgef
Posts: 4464
Joined: 17 Jul 2016, 01:02
Contact:

Re: Simulating Alt + Shift + Unicode on Windows

08 May 2017, 12:02

Hmm, I didn't expect that... I'll investigate later.
Helgef
Posts: 4464
Joined: 17 Jul 2016, 01:02
Contact:

Re: Simulating Alt + Shift + Unicode on Windows

08 May 2017, 12:31

Helgef wrote:

Code: Select all

Send,{Ctrl up}{Ctrl shift}
That is awkward, but I don't know why it would crash. At least here, the modifiers are released so there is no recursion of the hotkey

Code: Select all

A2  01D	i	u	2.39	LControl       	
A0  02A	i	u	0.00	LShift         	
55  016	i	d	0.00	u              	
55  016	i	u	0.00	u              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift 
Some corrections:

Code: Select all

^+u::
	SendInput,u
	Hotkey,shift up,sf24,on
	Hotkey,ctrl up,sf24,on
	holding:=1
	n:=""
	while holding {
		ctr:=A_Index
		Send,{Ctrl up}{shift up}
		Input,p, V L1,{esc}{space}{enter}{F24}
		n.=p
	}
	Hotkey,shift up,sf24,off
	Hotkey,ctrl up,sf24,off
	n:="0x" . n
	if n is integer
		SendInput,% "{bs " ctr "}{U+" n "}"
return
esc::exitapp
sf24:
	holding:=0
	Send,{F24}
return
aleskva
Posts: 5
Joined: 08 May 2017, 10:06

Re: Simulating Ctrl + Shift + Unicode on Windows

08 May 2017, 13:58

Unfortunately none of them works for me
Helgef
Posts: 4464
Joined: 17 Jul 2016, 01:02
Contact:

Re: Simulating Ctrl + Shift + Unicode on Windows

08 May 2017, 14:13

I have no other ideas for this specific way of doing it. I think the key combo+holding is quite awkward, I prefer the first version, some key combo + no holding, I might even keep that myself :)

Good luck ☕
aleskva
Posts: 5
Joined: 08 May 2017, 10:06

Re: Simulating Ctrl + Shift + Unicode on Windows

08 May 2017, 15:58

Helgef wrote:I have no other ideas for this specific way of doing it. I think the key combo+holding is quite awkward, I prefer the first version, some key combo + no holding, I might even keep that myself :)

Good luck ☕
I ended up with following script. I press Ctrl + Shift + u and release Ctrl and u. When holding Shift I write 1-5 letters and after pressing Ctrl again it will be processed:

Code: Select all

^+u::
	SendInput, u
	Input, num, V L5,{LControl}{RControl}
	SetFormat, IntegerFast, Hex
	len:=strlen(num)+1
	Send, {bs %len%}{U+%num%}
Return
For numpad I can press Ctrl + Shift + u and release them all. Then I write 1-5 letters and after pressing Ctrl again it will be processed.
Finally this solution is the best for me. I only miss following things or functionalities and hope they will be added to AHK soon:

Code: Select all

Input, num, V L5,{Shift Up} ; Shift Up is not working as ending key, Shift down or Shift is not working too

Code: Select all

SetKeyState, Control, Up ; or:
Send, {Control Up} ; not working for keys pressed physically
Complete Linux-like approach (not working):

Code: Select all

^+u::
	if ( GetKeyState("Control", "P") and GetKeyState("Shift", "P") ){
		Send, {Control Up} ; make pressed ctrl not apply on whatever
		ReverseNumpad ; make pressed shift not apply on numpad, but leave it applied to numbers over qwerty (Middle-European keyboard layout)
		SendInput, u
		Input, num, V L5,{Control Up}{Shift Up}
		SetFormat, IntegerFast, Hex
		len:=strlen(num)+1
		Send, {bs %len%}{U+%num%}
		ReverseNumpad ; back to normal state
	}
Return
I must thank both of you for your help with this as I'm happy my script is working like a charm. Also I still accept any other suggestions, how to make "complete Linux-like approach" or missing functionalities work :)

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Dom_Christo, Franktic, guyzyl, mikeyww and 32 guests