-
Notifications
You must be signed in to change notification settings - Fork 718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buger repoter :Solution to incorrect mouse position/鼠标位置不正确解决办法 #329
Comments
以下修改的代码位置在utils/utils.py ####新增代码
def get_screen_scaling():
gvars.genshin_window_rect = win32gui.GetWindowRect(hwnd)# 这里强制刷新,拖动游戏框会更新位置
'''获取屏幕的缩放比例'''
hDC = win32gui.GetDC(0)
"""获取真实的分辨率"""
real_wide = win32print.GetDeviceCaps(hDC, win32con.DESKTOPHORZRES)
"""获取缩放后的分辨率"""
screen_wide = win32api.GetSystemMetrics(0)
return round(real_wide / screen_wide, 4)
def get_y_offset():
"""上面的白边"""
w = gvars.genshin_window_rect[2]-gvars.genshin_window_rect[0]
h = gvars.genshin_window_rect[3]-gvars.genshin_window_rect[1]
now_ratio = h/w
if now_ratio>0.572:# 有白边
real_ratio = 1080/1920.0
return int(h-w*real_ratio) # 这里假设 宽度是绝对正确的(反正两边没白边)
return 0
####修改代码
def mouse_down(x, y, button=MOUSE_LEFT):
x=int(x/get_screen_scaling())
y=int(y/get_screen_scaling())+get_y_offset()
time.sleep(0.1)
xx,yy=x+gvars.genshin_window_rect[0], y+gvars.genshin_window_rect[1]
win32api.SetCursorPos((xx,yy))
win32api.mouse_event(mouse_list_down[button], xx, yy, 0, 0)
def mouse_move(dx, dy):
dx=int(dx/get_screen_scaling())
dy=int(dy/get_screen_scaling())#这里是移动,是相对量,不需要偏移量get_y_offset()
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, dx, dy, 0, 0)
def mouse_up(x, y, button=MOUSE_LEFT):
x=int(x/get_screen_scaling())
y=int(y/get_screen_scaling())+get_y_offset()
time.sleep(0.1)
xx, yy = x + gvars.genshin_window_rect[0], y + gvars.genshin_window_rect[1]
win32api.SetCursorPos((xx, yy))
win32api.mouse_event(mouse_list_up[button], xx, yy, 0, 0)
def mouse_click(x, y, button=MOUSE_LEFT):
mouse_down(x, y, button)
mouse_up(x, y, button)
def mouse_down_raw(x, y, button=MOUSE_LEFT):
x=int(x/get_screen_scaling())
y=int(y/get_screen_scaling())+get_y_offset()
xx, yy = x + gvars.genshin_window_rect[0], y + gvars.genshin_window_rect[1]
win32api.mouse_event(mouse_list_down[button], xx, yy, 0, 0)
def mouse_up_raw(x, y, button=MOUSE_LEFT):
x=int(x/get_screen_scaling())
y=int(y/get_screen_scaling())+get_y_offset()
xx, yy = x + gvars.genshin_window_rect[0], y + gvars.genshin_window_rect[1]
win32api.mouse_event(mouse_list_up[button], xx, yy, 0, 0)
def mouse_click_raw(x, y, button=MOUSE_LEFT):
mouse_down_raw(x, y, button)
mouse_up_raw(x, y, button) |
@7eu7d7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题:
放缩布局不是为100%时会导致鱼饵选择失败
下面可以看到操作范围上只有720p,放大1.5倍后才能一致
而分辨率是写死的,在获取图片的时候,直接获取长和宽的
并且存在分辨率不一致的问题如上面的1924x1120,实际上是1920x1080 明显1120比1080多了40像素,其原因是因为窗口化带来的问题(就是上面那个白条,如下图)
最终导致屏幕异常,没办法找到正确的饵料
The text was updated successfully, but these errors were encountered: