下記のようにして取得できました。
ありがとうございます。
C#
1 // IMEでキーが押されたかのフラグ
2 private const int WM_IME_COMPOSITION = 0x010F;
3 // 変換確定後文字取得に使用する値(ひらがな)
4 private const int GCS_RESULTSTR = 0x0800;
5 // 変換確定後文字取得に使用する値(1バイトカタカナ)
6 private const int GCS_RESULTREADSTR = 0x0200;
7 // IME入力中文字取得に使用する値(ひらがな)
8 private const int GCS_COMPSTR = 0x0008;
9 // IME入力中文字取得に使用する値(1バイトカタカナ)
10 private const int GCS_COMPREADSTR = 0x0001;
11 [DllImport("Imm32.dll")]
12 private static extern int ImmGetContext(IntPtr hWnd);
13 [DllImport("Imm32.dll")]
14 private static extern int ImmGetCompositionString(
15 int hIMC, int dwIndex, StringBuilder lpBuf, int dwBufLen);
16 [DllImport("Imm32.dll")]
17 private static extern bool ImmReleaseContext(IntPtr hWnd, int hIMC);
18
19
20
21public void GetImeText()
22{
23 var helper = new System.Windows.Interop.WindowInteropHelper(this);
24 int hIMC = ImmGetContext(helper.Handle);
25 int strLen = ImmGetCompositionString(hIMC, /*GCS_RESULTREADSTR*/GCS_RESULTSTR, null, 0);
26 StringBuilder str = new StringBuilder(strLen);
27
28 ImmGetCompositionString(hIMC, /*GCS_RESULTREADSTR*/GCS_RESULTSTR, str, str.Capacity);
29 ImmReleaseContext(helper.Handle, hIMC);
30
31 string txt3 = str.ToString().Substring(0, strLen / 2);
32
33 :