Get a program's Input Method

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Aleu
Newbie
Posts: 8
Joined: Mon Aug 20, 2007 2:51 am

Get a program's Input Method

Post by Aleu » Sun Sep 23, 2007 9:05 am

Some post previously seems relevant to this. Now I want to detect whether a program is using input method, such as Chinese. If so, change it to English.

This can avoid many troubles when you're using MS "send" command.
Script sample:

Setfocus>UltraEdit*
GetActiveWindow>window_title,X,Y
GetWindowHandle>window_title,handle
LibFunc>user32,GetWindowThreadProcessId,TID,handle,
LibFunc>user32,GetKeyboardLayout,KBhandle,TID
LibFunc>imm32,ImmIsIME,InputMethod,KBhandle
Messagemodal>InputMethod

If you're using InputMethod other than English, the InputMethod shall be 1.

Aleu
Newbie
Posts: 8
Joined: Mon Aug 20, 2007 2:51 am

Microsoft Word

Post by Aleu » Sun Sep 23, 2007 9:35 am

However!! The above script works well for simple word processing software such as Ultraedit, notepad, etc. It won't work for Microsoft Word!
This headache me very, very much.

Presently I appeal to Microsoft Word macro to change the input method to English. Here's the macro and you can use MS to automating it:

Option Explicit
Private Declare Function ActivateKeyboardLayout Lib "user32" (ByVal hkl As Long, ByVal flags As Long) As Long
Public hCurKBDLayout As Long
Sub autoexec()
hCurKBDLayout = 67699721 'English; Chinese1 -536606716; Chinese2 -535951356
ActivateKeyboardLayout hCurKBDLayout, 0
End Sub

Can any experts show some better way??? (and, can the macro above run in a temporary file other than in word macro?)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts