程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python analog keyboard input (with Python key position code table)

編輯:Python

stay Python In, we will simulate the keyboard for some input

Install third party libraries win32api( If not, you need to install )

1.Win+R, Input cmd Open the command line
2. Input pip install pypiwin32
The download website you actually visit is https://pypi.Python.org/simple/, This is a foreign website , Relatively slow
At this time, we can use domestic websites

Douban source

pip install pypiwin32 -i https://pypi.douban.com/simple

Tsinghua University source

pip install pypiwin32 -i https://pypi.tuna.tsinghua.edu.cn/simple

The import module

import win32api
import win32con

Enter the code

win32api.keybd_event(17, 0, 0, 0) #Ctrl
win32api.keybd_event(86, 0, 0, 0) #V
win32api.keybd_event(86, 0, win32con.KEYEVENTF_KEYUP, 0) # Release command
win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)

Python Key position code table

Key Key code Key Key code A65096B66197C67298D68399E694100F705101G716102H727103I738104J749105K75*106L76+107M77Enter108N78-109O79.110P80/111Q81F1112R82F2113S83F3114T84F4115U85F5116V86F6117W87F7118X88F8119Y89F9120Z90F10121Backspace8F11122Tab9F12123Clear12End35Enter13Home36Shift16LeftArrow37Control17UpArrow38Alt18RightArrow39Caps Lock20DownArrow40Esc27Insert45Spacebar32Delete46PageUp33Help47PageDown34NumLock144
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved