How can I set an edit control to be Latin-only? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
william_ahk
Posts: 36
Joined: 03 Dec 2018, 20:02

How can I set an edit control to be Latin-only?

Post by william_ahk » 25 Sep 2020, 19:02

When an input method is on one would have to switch it off to enter latin letters directly, is there any way to make an edit control declare that it only accepts latin letters, temporarily switch to English input, and switch back after losing focus?
User avatar
mikeyww
Posts: 4191
Joined: 09 Sep 2014, 18:38

Re: How can I set an edit control to be Latin-only?

Post by mikeyww » 25 Sep 2020, 19:10

One workaround could be to set temporary hotkeys that ignore characters that should not appear.
tmplinshi
Posts: 1600
Joined: 01 Oct 2013, 14:57

Re: How can I set an edit control to be Latin-only?  Topic is solved

Post by tmplinshi » 26 Sep 2020, 01:09

Code: Select all

DisableControlIME(hWnd, bDisable := true) {
	flag := bDisable ? 0x0020 ; IACE_IGNORENOCONTEXT
	                 : 0x0010 ; IACE_DEFAULT
	DllCall("Imm32\ImmAssociateContextEx", "ptr", hWnd, "ptr", 0, "uint", flag)
}

; Example
Gui, Add, Edit, xm w300 +HwndhEdit, 
Gui, Add, Checkbox, x+10 hp vcb2 gDisableIME, Disable IME
Gui, Add, Edit, xm w300, 
Gui, Show
Return

DisableIME:
	GuiControlGet, b,, % A_GuiControl
	DisableControlIME(hEdit, b)
Return

GuiClose:
ExitApp
User avatar
mikeyww
Posts: 4191
Joined: 09 Sep 2014, 18:38

Re: How can I set an edit control to be Latin-only?

Post by mikeyww » 26 Sep 2020, 05:30

That looks cool. Does that DLL call disable the non-Latin input? How does it do that?
william_ahk
Posts: 36
Joined: 03 Dec 2018, 20:02

Re: How can I set an edit control to be Latin-only?

Post by william_ahk » 27 Oct 2020, 07:29

@tmplinshi This is really gool (good&cool)! Thank you so much
Post Reply

Return to “Ask For Help”