![](/img/trans.png)
[英]Is there any way, in Python, to programmatically change the CAPS LOCK/NUM LOCK/SCROLL LOCK states on a hidraw device
[英]Python 3.x - Getting the state of caps-lock/num-lock/scroll-lock on Windows
您可以使用 ctypes 加載 user32.dll,然后使用nVirtKey = VK_CAPITAL (0x14)調用GetKeyState
def get_capslock_state():
import ctypes
hllDll = ctypes.WinDLL ("User32.dll")
VK_CAPITAL = 0x14
return hllDll.GetKeyState(VK_CAPITAL)
為 Python 3.x 安裝pywin32
這是檢查大寫鎖定狀態的示例。
from win32api import GetKeyState
from win32con import VK_CAPITAL
GetKeyState(VK_CAPITAL)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.