本文整理汇总了Python中win32gui.ClientToScreen方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.ClientToScreen方法的具体用法?Python win32gui.ClientToScreen怎么用?Python win32gui.ClientToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32gui
的用法示例。
在下文中一共展示了win32gui.ClientToScreen方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouse_drag
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def mouse_drag(self, pos1, pos2):
"""
鼠标拖拽
:param pos1: (x,y) 起点坐标
:param pos2: (x,y) 终点坐标
"""
pos1_s = win32gui.ClientToScreen(self.hwnd, pos1)
pos2_s = win32gui.ClientToScreen(self.hwnd, pos2)
screen_x = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
screen_y = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
start_x = pos1_s[0]*65535//screen_x
start_y = pos1_s[1]*65535//screen_y
dst_x = pos2_s[0]*65535//screen_x
dst_y = pos2_s[1]*65535//screen_y
move_x = np.linspace(start_x, dst_x, num=20, endpoint=True)[0:]
move_y = np.linspace(start_y, dst_y, num=20, endpoint=True)[0:]
self.mouse_move(pos1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
for i in range(20):
x = int(round(move_x[i]))
y = int(round(move_y[i]))
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE |
win32con.MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
time.sleep(0.01)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
示例2: tap
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def tap(self, x, y):
if self.run_time.stop:
return
x, y = int(x), int(y)
self.root.debug("Tapping at location ({},{})".format(x, y))
if self._debug:
# Helper to debug taps
input("waiting for confirmation press enter")
ox, oy = win32api.GetCursorPos()
curr_window = win32gui.GetForegroundWindow()
win32gui.ShowWindow(self.win_handle, win32con.SW_RESTORE)
x, y = int(x), int(y)
cx, cy = win32gui.ClientToScreen(self.win_handle, (x, y))
x, y = self.__calculate_absolute_coordinates__(cx, cy)
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE | win32con.MOUSEEVENTF_ABSOLUTE,
x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
time.sleep(20 / 1000)
win32api.SetCursorPos((ox, oy))
win32gui.SetActiveWindow(curr_window)
示例3: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l,t,r,b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
self._SetupList()
l,t,r,b = win32gui.GetClientRect(self.hwnd)
self._DoSize(r-l,b-t, 1)
示例4: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l,t,r,b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
示例5: rect
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def rect(self):
hwnd = self.hwnd
if not self.exclude_border:
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
else:
_left, _top, _right, _bottom = win32gui.GetClientRect(hwnd)
left, top = win32gui.ClientToScreen(hwnd, (_left, _top))
right, bottom = win32gui.ClientToScreen(hwnd, (_right, _bottom))
return Rect(left, top, right, bottom)
示例6: __init_rect_size
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def __init_rect_size(self):
hwnd = self.hwnd
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
if self.exclude_border:
_left, _top, _right, _bottom = win32gui.GetClientRect(hwnd)
left, top = win32gui.ClientToScreen(hwnd, (_left, _top))
right, bottom = win32gui.ClientToScreen(hwnd, (_right, _bottom))
self._rect = Rect(left, top, right, bottom)
self._size = Size(right-left, bottom-top)
示例7: mouse_move
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def mouse_move(self, pos, pos_end=None):
"""
模拟鼠标移动
:param pos: (x,y) 鼠标移动的坐标
:param pos_end=None: (x,y) 若pos_end不为空,则鼠标移动至以pos为左上角坐标pos_end为右下角坐标的区域内的随机位置
"""
pos2 = win32gui.ClientToScreen(self.hwnd, pos)
if pos_end == None:
win32api.SetCursorPos(pos2)
else:
pos_end2 = win32gui.ClientToScreen(self.hwnd, pos_end)
pos_rand = (random.randint(
pos2[0], pos_end2[0]), random.randint(pos2[1], pos_end2[1]))
win32api.SetCursorPos(pos_rand)
示例8: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l, t, r, b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen(desktop, (
(dt_r - dt_l) // 2, (dt_b - dt_t) // 2))
win32gui.MoveWindow(hwnd, centre_x - (r // 2), centre_y - (b // 2),
r - l, b - t, 0)
# self._SetupList()
l, t, r, b = win32gui.GetClientRect(self.hwnd)
self._DoSize(r - l, b - t, 1)
示例9: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l, t, r, b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen(desktop,
((dt_r - dt_l)//2,
(dt_b - dt_t)//2))
win32gui.MoveWindow(hwnd, centre_x-(r//2),
centre_y-(b//2), r-l, b-t, 0)
# self._SetupList()
l, t, r, b = win32gui.GetClientRect(self.hwnd)
self._DoSize(r-l, b-t, 1)
示例10: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ClientToScreen [as 别名]
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l, t, r, b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen(
desktop,
((dt_r-dt_l)//2, (dt_b-dt_t)//2))
win32gui.MoveWindow(hwnd, centre_x-(r//2),
centre_y-(b//2), r-l, b-t, 0)
# self._SetupList()
l, t, r, b = win32gui.GetClientRect(self.hwnd)
self._DoSize(r-l, b-t, 1)