hot key for change language Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
omar bishr
Posts: 92
Joined: 23 Nov 2020, 23:05

hot key for change language

Post by omar bishr » 27 Jan 2022, 14:24

i want edit that script to switch between arabic and english only so no German.

Code: Select all

; https://docs.microsoft.com/de-de/windows/desktop/Intl/language-identifier-constants-and-strings
F7:: SetDefaultKeyboardLang(0x02809) ; english
F8:: SetDefaultKeyboardLang(0x0407)  ; german
F9:: SetDefaultKeyboardLang(0x040D)  ; hebrew

; https://autohotkey.com/boards/viewtopic.php?f=6&t=18519
SetDefaultKeyboardLang(LocaleID){
	Static SPI_SETDEFAULTINPUTLANG := 0x005A, SPIF_SENDWININICHANGE := 2	
	Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
	VarSetCapacity(binaryLocaleID, 4, 0)
	NumPut(LocaleID, binaryLocaleID)

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: hot key for change language

Post by BoBo » 27 Jan 2022, 17:21

Code: Select all


Albanais

  00000401:   'Arabic Saudi Arabia'           //Arabe Arabie Saoudite

  00000801:   'Arabic Iraq'                   //Arabe Irak

  00000C01:   'Arabic Egypt'                  //Arabe Egypte

  00001001:   'Arabic Libya'                  //Arabe Libye

  00001401:   'Arabic Algeria'                 //Arabe Algerie

  00001801:   'Arabic Morocco'                //Arabe Maroc

  00001C01:   'Arabic Tunisia'                //Arabe Tunisie

  00002001:   'Arabic Oman'                   //Arabe Oman

  00002401:   'Arabic Yemen'                  //Arabe Yemen

  00002801:   'Arabic Syria'                  //Arabe Syrie

  00002c01:   'Arabic Jordan'                 //Arabe Jordanie

  00003001:   'Arabic Lebanon'                //Arabe Liban

  00003401:   'Arabic Kuwait'                 //Arabe Koweit

  00003801:   'Arabic UAE'                    //Arabe Emirats Arabes Unis

  00003c01:   'Arabic Bahrain'                //Arabe Bahrein

  00004001:   'Arabic Qatar'                   //Arabe Qatar
Probably one of these values will do the trick?

Source: https://delphi4arab.net/forum/archive/index.php/thread-1186.html
0x0407 | 0x00000407 | 00000407

omar bishr
Posts: 92
Joined: 23 Nov 2020, 23:05

Re: hot key for change language  Topic is solved

Post by omar bishr » 27 Jan 2022, 18:20

i think this is bad script i found script to change lang what ever it is just press f1:

Code: Select all

; This should be replaced by whatever your native language is. See 
; http://msdn.microsoft.com/en-us/library/dd318693%28v=vs.85%29.aspx
; for the language identifiers list.
ru := DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1)
en := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1)

f1::
w := DllCall("GetForegroundWindow")
pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0)
l := DllCall("GetKeyboardLayout", "UInt", pid)
if (l = en) 
{
    PostMessage 0x50, 0, %ru%,, A
}
else
{
PostMessage 0x50, 0, %en%,, A
}

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: hot key for change language

Post by BoBo » 27 Jan 2022, 18:48

Well, that other/first script isn't "bad".
Its main benefit - it assigns a language to a specific key.
That way you won't have to juggle through a bunch of languages if more than two are used.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: hot key for change language

Post by amateur+ » 27 Jan 2022, 19:01

@omar bishr, btw, what Windows hotkey do you use? Ctrl+Shift or Shift+Alt?
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

omar bishr
Posts: 92
Joined: 23 Nov 2020, 23:05

Re: hot key for change language

Post by omar bishr » 28 Jan 2022, 12:40

amateur+ wrote:
27 Jan 2022, 19:01
@omar bishr, btw, what Windows hotkey do you use? Ctrl+Shift or Shift+Alt?
Shift+Alt

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: hot key for change language

Post by amateur+ » 28 Jan 2022, 13:31

So why did you refuse simple sending Alt+Shift?

Code: Select all

F3::Send, {Alt Down}{Shift}{Alt Up}
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

bruin1953
Posts: 9
Joined: 22 Jan 2015, 10:27

Re: hot key for change language

Post by bruin1953 » 14 Jun 2023, 09:28

omar bishr wrote:
27 Jan 2022, 14:24
i want edit that script to switch between arabic and english only so no German.

Code: Select all

; https://docs.microsoft.com/de-de/windows/desktop/Intl/language-identifier-constants-and-strings
F7:: SetDefaultKeyboardLang(0x02809) ; english
F8:: SetDefaultKeyboardLang(0x0407)  ; german
F9:: SetDefaultKeyboardLang(0x040D)  ; hebrew

; https://autohotkey.com/boards/viewtopic.php?f=6&t=18519
SetDefaultKeyboardLang(LocaleID){
	Static SPI_SETDEFAULTINPUTLANG := 0x005A, SPIF_SENDWININICHANGE := 2	
	Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
	VarSetCapacity(binaryLocaleID, 4, 0)
	NumPut(LocaleID, binaryLocaleID)

I Use this simple one, since Capslock is useless:
Capslock::
Send, {Alt Down}{Shift Down}{Shift Up}{Alt Up}
SoundBeep 999, 1
return

Post Reply

Return to “Ask for Help (v1)”