Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automatic switching input method
#1
Hello, I have a long-term unresolved problem. The method I found in the forum did not solve my problem. I hope someone can provide some suggestions. Thanks in advance.

In autohotkey, I can use the following input method function to switch.
switchime("The name of the input method ")

How to implement it in QM? 
for example, in the following dialog box, when inputting in the edit box, it will automatically switch to the corresponding input method.


Macro Macro2
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 100 24 96 12 ""
;4 Static 0x54000000 0x0 16 24 68 10 "English input method"
;5 Static 0x54000000 0x0 16 52 70 10 "Chinese input method"
;6 Edit 0x54030080 0x200 100 52 96 13 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 6"
str e3 e6
if(!ShowDialog(dd 0 &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#2
Function GetInputLanguage
Code:
Copy      Help
;/
function# hwnd

ret GetKeyboardLayout(GetWindowThreadProcessId(hwnd 0))

Function SetInputLanguage
Code:
Copy      Help
;/
function hwnd lang

PostMessage hwnd WM_INPUTLANGCHANGEREQUEST 0 lang

test
Macro Macro367
Code:
Copy      Help
;swaps input languages of Notepad and WordPad

int w1=win("*Untitled - Notepad" "Notepad")
int w2=win("Document - WordPad" "WordPadClass")
int lang1=GetInputLanguage(w1)
int lang2=GetInputLanguage(w2)
out "0x%X" lang1
out "0x%X" lang2
SetInputLanguage w1 lang2
SetInputLanguage w2 lang1
#3
I just tested on the win10 system, the above code is successful, thank you  @Gintaras   Tongue


Forum Jump:


Users browsing this thread: 1 Guest(s)