回答編集履歴
1
追記
answer
CHANGED
@@ -6,4 +6,32 @@
|
|
6
6
|
user32 = WinDLL("user32")
|
7
7
|
user32.GetKeyState(0x90) # VK_NUMLOCKは動く
|
8
8
|
user32.GetKeyState(0x19) # VK_HANJAは動かない
|
9
|
-
```
|
9
|
+
```
|
10
|
+
|
11
|
+
# 追記(m-takeさんの情報を元に、、、できた!!)
|
12
|
+
|
13
|
+
```python
|
14
|
+
from ctypes import WinDLL
|
15
|
+
from threading import Thread
|
16
|
+
from time import sleep
|
17
|
+
from tkinter import Tk
|
18
|
+
|
19
|
+
|
20
|
+
def ime_check():
|
21
|
+
user32 = WinDLL("user32")
|
22
|
+
imm32 = WinDLL("imm32")
|
23
|
+
|
24
|
+
while True:
|
25
|
+
hWnd = user32.GetForegroundWindow()
|
26
|
+
hIMC = imm32.ImmGetContext(hWnd)
|
27
|
+
print("hWnd:", hWnd, "hIMC:", hIMC, "ImmGetOpenStatus:", imm32.ImmGetOpenStatus(hIMC))
|
28
|
+
imm32.ImmReleaseContext(hWnd, hIMC)
|
29
|
+
sleep(1)
|
30
|
+
|
31
|
+
|
32
|
+
Thread(target=ime_check, daemon=True).start()
|
33
|
+
root = Tk()
|
34
|
+
root.mainloop()
|
35
|
+
```
|
36
|
+
|
37
|
+
[同じプロセスじゃないとImmGetContext()が何も返さない](https://social.msdn.microsoft.com/Forums/expression/ja-JP/9bd07a1f-dbda-4d1f-bbdc-61df09ecdfc3/ime1239829366249072146224471260412786112395123881235612390)という点に引っかかりましたが。
|