Python 3.x - 在 Windows 上获取 caps-lock/num-lock/scroll-lock 的状态 [英] Python 3.x - Getting the state of caps-lock/num-lock/scroll-lock on Windows

查看:60
本文介绍了Python 3.x - 在 Windows 上获取 caps-lock/num-lock/scroll-lock 的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如问题所问,我知道这是可能的 Linux,但我找不到适用于 Windows 的最新内容.甚至有可能吗?

Just as the question asks, I know this is possible on Linux, but I couldn't find anything recent for Windows. Is it even possible?

推荐答案

可以使用 ctypes 加载 user32.dll,然后调用 GetKeyStatenVirtKey = VK_CAPITAL (0x14)

You can use ctypes to load user32.dll and then call GetKeyState with nVirtKey = VK_CAPITAL (0x14)

def get_capslock_state():
    import ctypes
    hllDll = ctypes.WinDLL ("User32.dll")
    VK_CAPITAL = 0x14
    return hllDll.GetKeyState(VK_CAPITAL)

这篇关于Python 3.x - 在 Windows 上获取 caps-lock/num-lock/scroll-lock 的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆