2022年5月13日 星期五

ime

 https://p0w3rsh3ll.wordpress.com/2013/06/07/about-keyboard-layouts/

 https://social.technet.microsoft.com/Forums/en-US/2a46ae38-2202-4286-9b46-35bc6e60e861/what-command-can-be-run-from-the-cmd-to-inquire-about-the-language-layout-that-is-used-right-now?forum=w7itproui

 

For the current input language you can try using

reg query "HKCU\Keyboard Layout\Preload" /v 1

The return value includes an eight digit hex value. The first four digits indicate either default layout for the language (all zeros) or a variation (non-zero). The last four digits are the locale id - see:

http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx

From this table, you can see in the example above my input language is English - Australia.

For the keyboard layout you could try

WMIC Path Win32_Keyboard Get Layout

0409 is an English - US keyboard.

For a few other ideas/methods try reading

http://p0w3rsh3ll.wordpress.com/2013/06/07/about-keyboard-layouts/ 




About keyboard layouts
Posted on June 7, 2013   

A colleague from the helpdesk team recently asked if I could report the keyboad layout set before users log onto the computer.

I started digging into WMI classes by typing

Get-CimClass -ClassName *Keyboard*

Then did:

Get-CimInstance Win32_Keyboard

… and noticed the Layout property.

Both the MSDN page about the WMI Win32_Keyboard class…

…and the following powershell commands…

([wmiclass]'Win32_Keyboard').GetText("MOF")            
([wmiclass]'CIM_Keyboard').GetText("MOF")

…confirmed that the layout property is returned as a string value.

The problem with this value is that it’s not human readable and represents actually a hexadecimal value.



The problem with this value is that it’s not human readable and represents actually a hexadecimal value.
Although I can find the mapping of hexadecimal values to a user friendly value in the following registry key HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layout\DosKeybCodes, I decided to go another way.

First, do you know that you can use DISM.exe locally:

ime

 IEnumTfLanguageProfiles = interface
['{3D61BF11-AC5F-42C8-A4CB-931BCC28C744}']
function Next(ulCount: Cardinal; const pProfile: PF_LANGUAGEPROFILE; out pcFetch: Cardinal): HRESULT; stdcall;
MSDN  

HRESULT Next(    ULONG ulCount<!---->,
  TF_LANGUAGEPROFILE* pProfile<!---->,
  ULONG* pcFetch<!----> );

Parameters

ulCount
    [in] Specifies the number of elements to obtain.
pProfile
    [out] Pointer to an array of TF_LANGUAGEPROFILE structures that receives the requested data. This array must be at least ulCount elements in size.
pcFetch
    [out] Pointer to a ULONG value that receives the number of elements obtained. This value can be less than the number of items requested. This parameter can be NULL.

 
    Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)]
    TF_LANGUAGEPROFILE[] profiles, out int fetched);

 

 

 

 

 


type
PF_LANGUAGEPROFILE = ^TF_LANGUAGEPROFILE;
TF_LANGUAGEPROFILE = packed record
clsid: TGUID;
langid: smallint;
catid: TGUID;
fActive: WordBool;
guidProfile: TGUID;
end;

IEnumGUID = interface
['{0002E000-0000-0000-C000-000000000046}']
function Next(celt: Cardinal; out rgelt: TGUID; out pcFetched: Cardinal): HRESULT; stdcall;
function Skip(celt: Cardinal): HRESULT; stdcall;
function Reset: HRESULT; stdcall;
function Clone(out ppEnum: IEnumGUID): HRESULT; stdcall;
end;

IEnumTfLanguageProfiles = interface
['{3D61BF11-AC5F-42C8-A4CB-931BCC28C744}']
function Clone(out ppEnum: IEnumTfLanguageProfiles): HRESULT; stdcall;
function Next(ulCount: Cardinal; const pProfile: PF_LANGUAGEPROFILE; out pcFetch: Cardinal): HRESULT; stdcall;
function Reset: HRESULT; stdcall;
function Skip(ulCount: Cardinal): HRESULT; stdcall;
end;

ITfInputProcessorProfiles = interface
['{1F02B6C5-7842-4EE6-8A0B-9A24183A95CA}']
function Register(const clsid: TGUID): HRESULT; stdcall;
function Unregister(const clsid: TGUID): HRESULT; stdcall;
function AddLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; const pchDesc: WideString; cchDesc: Cardinal; const pchIconFile: WideString; cchFile, uIconIndex: Cardinal): HRESULT; stdcall;
function RemoveLanguageProfile(const clsid: TGUID; langid: smallint; out guidProfile: TGUID): HRESULT; stdcall;
function EnumInputProcessorInfo(out ppEnum: IEnumGUID): HRESULT; stdcall;
function GetDefaultLanguageProfile(langid: smallint; const catid: TGUID; out clsid: TGUID; out guidProfile: TGUID): HRESULT; stdcall;
function SetDefaultLanguageProfile(langid: smallint; const clsid: TGUID; const guidProfile: TGUID): HRESULT; stdcall;
function ActivateLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfiles: TGUID): HRESULT; stdcall;
function GetActiveLanguageProfile(const clsid: TGUID; out langid: smallint; out guidProfile: TGUID): HRESULT; stdcall;
function GetLanguageProfileDescription(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; out pbstrProfile: WideString): HRESULT; stdcall;
function GetCurrentLanguage(out langid: smallint): HRESULT; stdcall;
function ChangeCurrentLanguage(langid: smallint): HRESULT; stdcall;
function GetLanguageList(out ppLangId: pointer; out ulCount: Cardinal): HRESULT; stdcall;
function EnumLanguageProfiles(langid: smallint; out ppEnum: IEnumTfLanguageProfiles): HRESULT; stdcall;
function EnableLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; fEnable: WordBool): HRESULT; stdcall;
function IsEnabledLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; out fEnabled: WordBool): HRESULT; stdcall;
function EnableLanguageProfileByDefault(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; fEnabled: WordBool): HRESULT; stdcall;
function SubstituteKeyboardLayout(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; hKL: pointer): HRESULT; stdcall;
end;

function TF_CreateInputProcessorProfiles(out profiles: ITfInputProcessorProfiles): HRESULT; stdcall; external 'msctf.dll'; 


https://github.com/ryancheung/ImeSharp

IterateSubKeys(Registry.CurrentUser, "SOFTWARE\\Microsoft\\CTF\\TIP\\" + subKeyName + "\\LanguageProfile",

https://www.xujun.org/note-48842.html

文/黄忠成

  ComImport SecurityCritical SuppressUnmanagedCodeSecurity

Guid  “1F02B6C5-7842-4EE6-8A0B-9A24183A95CA” ),
      InterfaceType ComInterfaceType  .InterfaceIsIUnknown)]
   ITfInputProcessorProfiles
 
    
 
 
 
 
 https://github.com/xyzzy-022/xyzzy/issues/170
 Vista で読みから変換候補リストを取得する Text Services Framework
 http://hp.vector.co.jp/authors/VA050396/tech_01.html
 
 
 https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/Win7Samples/winui/tsf
 https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/Win7Samples/winui/tsf/tsfapp/tsfapp.cpp
https://docs.microsoft.com/en-us/windows/win32/api/_tsf/
 msctf_TLB.pas
 https://github.com/lantaoxu/Windows-Server-2003/blob/5c6fe3db626b63a384230a1aa6b92ac416b0765f/windows/advcore/ctf/inc/msime.h
https://pastebin.com/PBcJeuKV 
TSF "Text Services Framework"」の項でチョット触れましたが、これを実現するために ImmGetConversionList 関数を使う人がいます。この関数を使っても不可能ではありませんが、そもそも使うべき関数を間違っています。ImmGetCompositionString 関数ならズバリな解答を得ることができます。しかも、Windows Vista でも問題なく使えます。
http://www.kanazawa-net.ne.jp/~pmansato/net/net_tech_ime.htm
http://hp.vector.co.jp/authors/VA050396/tech_01.html
ImmGetConversionListの代替は?
https://www.petitmonte.com/bbs/answers?question_id=6145
https://docs.microsoft.com/zh-tw/windows/win32/api/msime/

//L"MSIME.China";
//L"MSIME.Japan";
//L"MSIME.Taiwan";
//L"MSIME.Taiwan.ImeBbo";
 
 
mepad.h
imm.h
immdev.h
msime.h
msimeapi.h
 
 Text Services Framework, you need these headers:

    ctffunc.h
    ctfspui.h
    ctfutb.h
    inputscope.h
    msaatext.h
    msctf.h
 
 
 

ime

 GetSystemMetrics WM_IME_CONTROL

https://docs.microsoft.com/zh-TW/windows/win32/intl/nls-terminology

 code  ImmGetCandidateList

https://docs.microsoft.com/zh-tw/windows/win32/intl/input-method-manager

https://docs.microsoft.com/zh-tw/windows/win32/intl/input-method-manager-messages

https://mugichoko.hatenablog.com/entry/2018/10/27/003856

https://dragon-john.blogspot.com/2013/06/c-win7.html