V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
hititan
V2EX  ›  Python

请问 Python 是否有这样的库?

  •  
  •   hititan · Jul 16, 2017 · 5969 views
    This topic created in 3207 days ago, the information mentioned may be changed or developed.

    小弟不才,请问 python 是否有操作其他应用软件的库?比如用 python 操控 ‘酷狗音乐软件’,让其在后台隐藏运行,没有任何显示窗口,并能操控其所有参数,比如选哪首歌和控制音量 如果有这样的多个库,请告知,非常感谢

    14 replies    2017-07-18 22:13:47 +08:00
    yonka
        1
    yonka  
       Jul 16, 2017
    要看对应的程序有没有给出暴露接口的 dll 吧。
    tnjin
        2
    tnjin  
       Jul 16, 2017
    有操作 windows UI 的库,关键词:pywin32
    liyoubin37
        3
    liyoubin37  
       Jul 16, 2017 via Android
    在 windows 下操作外部程序的窗口可以用 pywinauto,但对于酷狗、qq 等 DriectUI 目前只知道 Accessible 的方式可以。
    Mountain
        4
    Mountain  
       Jul 16, 2017
    @liyoubin37 #3 模拟按快捷键怎么样,不过估计可控的操作就少。。。
    ldbC5uTBj11yaeh5
        5
    ldbC5uTBj11yaeh5  
       Jul 16, 2017 via Android   ❤️ 1
    来来来,国人专家来拯救楼主了 https://github.com/yinkaisheng/Python-UIAutomation-for-Windows
    hititan
        6
    hititan  
    OP
       Jul 16, 2017
    非常感谢楼上的回复,我搜索下楼上几位提到的方法,希望有知道更多的库,请告知
    Betacoefficient
        7
    Betacoefficient  
       Jul 16, 2017
    @jigloo 这个我觉得人才中的人才啊。
    tangyouze
        8
    tangyouze  
       Jul 16, 2017 via iPhone
    比较推荐用按键精灵做类似的功能 我用过一些 python 的库 功能性和稳定性都不如按键精灵 如果项目规模大的话 可以使用按键精灵写底层的服务 比如控制音量 用 python 写外部的接口 比如自动化脚本 监听快捷键
    liuzhiyong
        9
    liuzhiyong  
       Jul 16, 2017
    有的,我就搞过,主要是利用 Windows 的 API。
    liuzhiyong
        10
    liuzhiyong  
       Jul 16, 2017   ❤️ 1
    贴几行代码吧:

    ……
    import ctypes
    ……
    GetWindowText = ctypes.windll.user32.GetWindowTextW
    ……
    ShowWindow = ctypes.windll.user32.ShowWindow
    ……

    虽然是“ user32 ”,但是 64 位的 Windows 也能用。
    intohole
        11
    intohole  
       Jul 16, 2017
    有个 python 终端的听歌用的 你可以搜下
    jimzhong
        12
    jimzhong  
       Jul 16, 2017 via Android
    如果有 com 接口可以用 pywin32
    ysc3839
        13
    ysc3839  
       Jul 17, 2017 via Android
    操作窗口等操作系统范畴的话,Windows 和 Linux 都可以用 ctypes 配合系统 API。Windows 还可以用 pywin32,写起来更方便。macOS 的话必须用 pyobjc。
    操作软件的话,要看软件给没给接口,这就很难说了。酷狗估计不会给接口,变通方案是模拟按快捷键。
    hititan
        14
    hititan  
    OP
       Jul 18, 2017
    非常感谢楼上的回答,再次感谢。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   940 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 21:41 · PVG 05:41 · LAX 14:41 · JFK 17:41
    ♥ Do have faith in what you're doing.