備忘錄import
win32api
import
win32con
win32api.keybd_event(17,0,0,0) #
ctrl鍵位碼是17
win32api.keybd_event(86,0,0,0) #
v鍵位碼是86
win32api.keybd_event(86,0,win32con.keyeventf_keyup,0) #
釋放按鍵
win32api.keybd_event(17,0,win32con.keyeventf_keyup,0)
下面時一些常見的鍵值碼和鍵的對應:
字母和數字鍵 數字小鍵盤的鍵 功能鍵 其它鍵
鍵 鍵碼 鍵 鍵碼 鍵 鍵碼 鍵 鍵碼
a 65 0 96 f1 112 backspace 8
b 66 1 97 f2 113 tab 9
c 67 2 98 f3 114 clear 12
d 68 3 99 f4 115 enter 13
e 69 4 100 f5 116 shift 16
f 70 5 101 f6 117 control 17
g 71 6 102 f7 118 alt 18
h 72 7 103 f8 119 caps lock 20
i 73 8 104 f9 120 esc 27
j 74 9 105 f10 121 spacebar 32
k 75 * 106 f11 122 page up 33
l 76 + 107 f12 123 page down 34
m 77 enter 108 end 35
n 78 - 109 home 36
o 79 . 110 left arrow 37
p 80 / 111 up arrow 38
q 81 right arrow 39
r 82 down arrow 40
s 83 insert 45
t 84 delete 46
u 85 help 47
v 86 num lock 144
w 87
x 88
y 89
z 90
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
Python模擬鍵盤輸入
2.程式實現 import win32api import win32con win32api.keybd event 17,0,0,0 ctrl鍵位碼是17 win32api.keybd event 86,0,0,0 v鍵位碼是86 win32api.keybd event 86,0,win32c...
用Python模擬鍵盤輸入
pywin安裝模組 import win32api import win32con win32api.keybd event 17,0,0,0 ctrl鍵位碼是17 win32api.keybd event 86,0,0,0 v鍵位碼是86 win32api.keybd event 86,0,win...
python鍵盤監聽及模擬鍵盤輸入
import sys,os from pynput.keyboard import controller,key,listener import datetime def on press key try nowtime datetime.datetime.now strftime h m s ex...