teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

試したこと② 追加

2021/03/18 12:59

投稿

python01
python01

スコア20

title CHANGED
File without changes
body CHANGED
@@ -59,6 +59,60 @@
59
59
  VK_KANJI = pg.platformModule.keyboardMapping['kanji']
60
60
  print(ctypes.windll.user32.GetKeyState(VK_KANJI))
61
61
  ```
62
+
63
+
64
+ ### 試したこと② 3/18追加
65
+ - 各動作時のキー状態確認
66
+  windowsキーを押すと0になっているようです。
67
+
68
+ ```Python
69
+ import pyautogui as pg
70
+ import ctypes
71
+ import time
72
+
73
+ VK_KANJI = pg.platformModule.keyboardMapping['kanji']
74
+
75
+ print("起動直後:",ctypes.windll.user32.GetKeyState(VK_KANJI))
76
+
77
+ pg.press('win')
78
+ print("win入力後:",ctypes.windll.user32.GetKeyState(VK_KANJI))
79
+
80
+ pg.write('mail')
81
+ time.sleep(1)
82
+ pg.press('enter')
83
+ time.sleep(1)
84
+ print("メールアプリ開いた後:",ctypes.windll.user32.GetKeyState(VK_KANJI))
85
+
86
+ pg.press('kanji')
87
+ print("press'kanji'後:",ctypes.windll.user32.GetKeyState(VK_KANJI))
88
+
89
+ if ctypes.windll.user32.GetKeyState(VK_KANJI) == 0:
90
+ pg.press('kanji')
91
+ print("おしました")
92
+ print("press'kanji'後:",ctypes.windll.user32.GetKeyState(VK_KANJI))
93
+
94
+ pg.press("a")
95
+ ```
96
+ ↓出力結果
97
+ ```
98
+ 起動直後: 1
99
+ win入力後: 0
100
+ メールアプリ開いた後: 0
101
+ press'kanji'後: 1
102
+ press'kanji'後: 1
103
+ ※毎回同じ出力
104
+ ```
105
+
106
+
107
+
108
+ - 参考資料確認
109
+  難しくて詳細は理解できていませんが、
110
+  下記資料によると、日本語入力キーの取得状態は
111
+  アプリが変わると認識できないようです。
112
+
113
+ https://teratail.com/questions/137570
114
+
115
+
62
116
  ### 補足情報(FW/ツールのバージョンなど)
63
117
 
64
118
  OS:windows10 64bit

1

タイトル変更

2021/03/18 12:59

投稿

python01
python01

スコア20

title CHANGED
@@ -1,1 +1,1 @@
1
- 半角/全角ボタンがONの時、常にOFFの状態にする
1
+ 半角/全角ボタン常にOFFの状態にする
body CHANGED
File without changes