inputOpj.EndKey

Report problems with documented functionality
aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

inputOpj.EndKey

10 Apr 2024, 11:53

In the function that i made is sometimes pressed instead of the name of the key
The letter of that word is returned in the language of that keyboard

Code: Select all

GetKey(Timeout?) {

		inputOpj := InputHook("S")	
		inputOpj.VisibleNonText := false
		inputOpj.VisibleText := false

		inputOpj.KeyOpt("{All}", "E")
		inputOpj.Start()
		inputOpj.Wait(Timeout?)

		return inputOpj.EndKey
	}
msgbox GetKey() ;=> If the keyboard is Farsi, it will return Farsi letters, while I asked for Endkey, not input (SOMETIMES)
lexikos
Posts: 9624
Joined: 30 Sep 2013, 04:07
Contact:

Re: inputOpj.EndKey

11 Apr 2024, 21:34

If I'm understanding you correctly, you are getting Farsi letters from EndKey but you are not expecting Farsi letters. So what are you expecting?

Keys which correspond to individual characters are "named" by the character that they produce, which depends on keyboard layout. If I'm understanding you correctly, EndKey returning Farsi letters is by design (assuming the returned letter corresponds to that key).
Note that EndKey returns the "normalized" name of the key [...]. GetKeyName can be used to retrieve the normalized name.
aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

Re: inputOpj.EndKey

14 Apr 2024, 21:51

lexikos wrote:
11 Apr 2024, 21:34
If I'm understanding you correctly, you are getting Farsi letters from EndKey but you are not expecting Farsi letters. So what are you expecting?

Keys which correspond to individual characters are "named" by the character that they produce, which depends on keyboard layout. If I'm understanding you correctly, EndKey returning Farsi letters is by design (assuming the returned letter corresponds to that key).
Note that EndKey returns the "normalized" name of the key [...]. GetKeyName can be used to retrieve the normalized name.
You are right, but why does it return English letters in most cases, regardless of the keyboard layout?
lexikos
Posts: 9624
Joined: 30 Sep 2013, 04:07
Contact:

Re: inputOpj.EndKey

20 Apr 2024, 08:34

GetKeyName is most definitely entirely dependent on the keyboard layout for single-character key names. If the VK is not between A (vk41) and Z (vk5A), it uses MapVirtualKeyEx to retrieve the corresponding character, according to the keyboard layout. For the A - Z keys (which MapVirtualKeyEx always maps to those ASCII letters), it instead uses ToUnicodeEx to translate the VK to a character according to the keyboard layout.

However, GetKeyName uses the script's current keyboard layout. Depending on the OS and settings, changing your keyboard layout might not affect the script, particularly if the script doesn't have an active window. Doing something like showing a MsgBox or ListLines prior to calling GetKeyName may affect the result.

Even so, if I switch to a Farsi keyboard layout and run the following script, I don't see any English letters (in the message text):

Code: Select all

Loop 255
    if StrLen(k := GetKeyName(Format("vk{:x}",A_Index))) = 1
        s .= k
MsgBox s
EndKey uses the same method of translation, dependent on the script's keyboard layout at the time you retrieve its value. As far as I can tell, your script similarly returns only Farsi letters if that keyboard layout is active.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 14 guests