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
stone000
V2EX  ›  Python

[求助] Pyautogui 不同屏幕分辨率處理

  •  
  •   stone000 · 2020-12-11 10:03:01 +08:00 · 1255 次点击
    这是一个创建于 1230 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Pyautogui 不同屏幕分辨率我是用以下方法,但是結果不准,還有其他方法嗎?
    先獲取當前屏幕分辨率,再跟原始 1440*900 對比,求出相應比例,然後所有用到坐標的地方乘以這個比例

    import pyautogui as ag
    import time
    import os

    while True:
    oldX, oldY = ag.position()
    time.sleep(0.3)
    nowX, nowY = ag.position()

    if nowX!=oldX or nowY!=oldY:
    os.system('cls')
    print(nowX,nowY)
    ClericPy
        1
    ClericPy  
       2020-12-11 19:56:23 +08:00
    我定位都是以图搜坐标, 只要保证缩放比一致就没出过问题, 偶尔要加个容错率... 只要用除法肯定有误差

    早年间用 ahk, 现在 pyautogui 也用过(似乎就是截图在内存里 pillow 定位)

    直接看你代码实在没看出来你要做啥
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5304 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 05:48 · PVG 13:48 · LAX 22:48 · JFK 01:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.