推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
commoccoom
V2EX  ›  Python

用 Python 模拟键盘事件

  •  
  •   commoccoom · Oct 4, 2015 · 5611 views
    This topic created in 3943 days ago, the information mentioned may be changed or developed.
    当按下键盘 E 键 时 , E , Q 键都按了

    给几个关键词也行,搜索了一下,没找到可行的方法
    10 replies    2015-10-05 20:26:15 +08:00
    fasling
        1
    fasling  
       Oct 4, 2015   ❤️ 1
    用 PyHook 拦截键盘事件, 获取到 E 键按下的消息.
    用 SendKeys 模拟键盘消息, 按下 E 键和 Q 键.
    Windows 下应该没问题,Mac 下估计不行.
    楼主是想自己写游戏助手?
    shoaly
        2
    shoaly  
       Oct 4, 2015
    auto hot key 已经非常简单易用了... 不用折腾 python 了...
    zckevin
        3
    zckevin  
       Oct 4, 2015   ❤️ 1
    commoccoom
        4
    commoccoom  
    OP
       Oct 4, 2015
    @shoaly

    就是想用 Python 试试,没别的
    commoccoom
        5
    commoccoom  
    OP
       Oct 4, 2015
    @zckevin

    win 系统
    tcsky
        6
    tcsky  
       Oct 4, 2015
    建议试试大漠插件,写游戏脚步的人常用的,
    不需要那么复杂功能的话直接用 win32com
    commoccoom
        7
    commoccoom  
    OP
       Oct 4, 2015
    @fasling
    https://gist.github.com/chnt7305/e546a629b40b8bff55d7

    找到了一个例子,但是怎么获取 E 键的信息 这里只有所有按键的信息
    fasling
        8
    fasling  
       Oct 5, 2015
    @commoccoom
    你不都获取到所有的按键了嘛?看看哪个是 E 不就行了。
    比如这样的:
    if event.Key == 'E':
    print "按下了 E"
    commoccoom
        9
    commoccoom  
    OP
       Oct 5, 2015
    @fasling
    行了,谢谢!
    w88975
        10
    w88975  
       Oct 5, 2015
    @tcsky 表示用大漠写游戏外挂挺好使的 大部分语言都能胜任。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1176 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 18:06 · PVG 02:06 · LAX 11:06 · JFK 14:06
    ♥ Do have faith in what you're doing.