推荐学习书目
› 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 · 5803 views
    This topic created in 4064 days ago, the information mentioned may be changed or developed.
    当按下键盘 E 键 时 , E , Q 键都按了

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

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

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

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