回答編集履歴

1

追記

2018/07/30 05:26

投稿

YouheiSakurai
YouheiSakurai

スコア6142

test CHANGED
@@ -15,3 +15,59 @@
15
15
  user32.GetKeyState(0x19) # VK_HANJAは動かない
16
16
 
17
17
  ```
18
+
19
+
20
+
21
+ # 追記(m-takeさんの情報を元に、、、できた!!)
22
+
23
+
24
+
25
+ ```python
26
+
27
+ from ctypes import WinDLL
28
+
29
+ from threading import Thread
30
+
31
+ from time import sleep
32
+
33
+ from tkinter import Tk
34
+
35
+
36
+
37
+
38
+
39
+ def ime_check():
40
+
41
+ user32 = WinDLL("user32")
42
+
43
+ imm32 = WinDLL("imm32")
44
+
45
+
46
+
47
+ while True:
48
+
49
+ hWnd = user32.GetForegroundWindow()
50
+
51
+ hIMC = imm32.ImmGetContext(hWnd)
52
+
53
+ print("hWnd:", hWnd, "hIMC:", hIMC, "ImmGetOpenStatus:", imm32.ImmGetOpenStatus(hIMC))
54
+
55
+ imm32.ImmReleaseContext(hWnd, hIMC)
56
+
57
+ sleep(1)
58
+
59
+
60
+
61
+
62
+
63
+ Thread(target=ime_check, daemon=True).start()
64
+
65
+ root = Tk()
66
+
67
+ root.mainloop()
68
+
69
+ ```
70
+
71
+
72
+
73
+ [同じプロセスじゃないとImmGetContext()が何も返さない](https://social.msdn.microsoft.com/Forums/expression/ja-JP/9bd07a1f-dbda-4d1f-bbdc-61df09ecdfc3/ime1239829366249072146224471260412786112395123881235612390)という点に引っかかりましたが。