Python win32gui.ClientToScreen() Examples
The following are 10
code examples of win32gui.ClientToScreen().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32gui
, or try the search function
.
Example #1
Source File: steam.py From Yugioh-bot with MIT License | 14 votes |
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)
Example #2
Source File: win32gui_dialog.py From ironpython2 with Apache License 2.0 | 6 votes |
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)
Example #3
Source File: win32rcparser_demo.py From ironpython2 with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: windows.py From ATX with Apache License 2.0 | 6 votes |
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)
Example #5
Source File: windows.py From ATX with Apache License 2.0 | 6 votes |
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)
Example #6
Source File: game_ctl.py From onmyoji_bot with GNU General Public License v3.0 | 6 votes |
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)
Example #7
Source File: console.py From eavatar-me with Apache License 2.0 | 6 votes |
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)
Example #8
Source File: notice_dlg.py From eavatar-me with Apache License 2.0 | 6 votes |
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)
Example #9
Source File: simpledialog.py From eavatar-me with Apache License 2.0 | 6 votes |
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)
Example #10
Source File: game_ctl.py From onmyoji_bot with GNU General Public License v3.0 | 4 votes |
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)