cycling through input languages Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
surfactant
Posts: 99
Joined: 28 Jun 2019, 01:07

cycling through input languages

23 Jun 2021, 23:12

Default Keyboard Lang https://www.autohotkey.com/boards/viewtopic.php?f=6&t=18519#p233011

Aafter reading the thread I created my codes for cycling through input languages.

Code: Select all

$AppsKey::
    WinExist("A")
    ControlGetFocus, CtrlInFocus
    PostMessage, 0x50, 2,, %CtrlInFocus%
return
Q1:

The code appears to be only effective for the current active application.

But my test shows that, the active input language is consistent for all the running applications (Win10). Yes, this is what I want (sheer luck?). How can I modify the code to cycling through input langages exactly for all the running applications, not just for the active application?

Q2:

The code above fails to work when certain application WITHOUT text input focus is active. How can it be fixed?

Thank you!
surfactant
Posts: 99
Joined: 28 Jun 2019, 01:07

Re: cycling through input languages

24 Jun 2021, 01:42

@AHKStudent It's already in the original post. Thanks!
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: cycling through input languages  Topic is solved

24 Jun 2021, 09:17

either:
  1. remap a key to the original windows shortcut

    Code: Select all

    $AppsKey::#Space ; or whatever u have the change language shortcut bound to
  2. create ur own input-capable window and keep it around so u can post to it instead of to the active window(which may not be input-capable)

    Code: Select all

    #NoEnv
    #SingleInstance Force
    
    Gui New, +HwndhGui +ToolWindow ; toolwindow required to get rid of taskbar icon
    Gui Add, Edit, HwndhEdit ; input-capable control required to handle WM_INPUTLANGCHANGEREQUEST
    Gui Show, x-9999 y-9999 NoActivate Hide ; render the GUI somewhere super-offscreen
    
    $AppsKey::
    	Gui %hGui%: Show ; window needs to be active to process the WM_INPUTLANGCHANGEREQUEST msg
    
    	DllCall("PostMessage"
    		, "Ptr", hEdit
    		, "UInt", 0x0050 ; WM_INPUTLANGCHANGEREQUEST
    		, "Ptr", 0x0002 ; INPUTLANGCHANGE_FORWARD
    		, "Ptr", 0)
    
    	Sleep 50 ; some delay required to allow the posted msg to be processed. decrease as needed
    	Gui %hGui%: Hide ; hide again to shift keyboard focus back to whatever window used to be active
    return
surfactant
Posts: 99
Joined: 28 Jun 2019, 01:07

Re: cycling through input languages

24 Jun 2021, 09:56

@swagfag Thanks a lot for the carefully annotated codes!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 329 guests