V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2017-07-16 15:42:09 +08:00 · 4976 次点击
    这是一个创建于 2476 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

    虽然是“ user32 ”,但是 64 位的 Windows 也能用。
    intohole
        11
    intohole  
       2017-07-16 22:55:47 +08:00
    有个 python 终端的听歌用的 你可以搜下
    jimzhong
        12
    jimzhong  
       2017-07-16 23:35:20 +08:00 via Android
    如果有 com 接口可以用 pywin32
    ysc3839
        13
    ysc3839  
       2017-07-17 17:33:33 +08:00 via Android
    操作窗口等操作系统范畴的话,Windows 和 Linux 都可以用 ctypes 配合系统 API。Windows 还可以用 pywin32,写起来更方便。macOS 的话必须用 pyobjc。
    操作软件的话,要看软件给没给接口,这就很难说了。酷狗估计不会给接口,变通方案是模拟按快捷键。
    hititan
        14
    hititan  
    OP
       2017-07-18 22:13:47 +08:00
    非常感谢楼上的回答,再次感谢。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2879 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 07:25 · PVG 15:25 · LAX 00:25 · JFK 03:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.