def _DoSize(self, cx, cy, repaint=1): # right-justify the textbox. ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT) l, t, r, b = win32gui.GetWindowRect(ctrl) l, t = win32gui.ScreenToClient(self.hwnd, (l, t)) r, b = win32gui.ScreenToClient(self.hwnd, (r, b)) win32gui.MoveWindow(ctrl, l, t, cx - l - 5, b - t, repaint) # The button. ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_OK) l, t, r, b = win32gui.GetWindowRect(ctrl) l, t = win32gui.ScreenToClient(self.hwnd, (l, t)) r, b = win32gui.ScreenToClient(self.hwnd, (r, b)) w = r - l win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b - t, repaint)
def append_message(self, msg): ctrl = win32gui.GetDlgItem(self.hwnd, IDC_MESSAGE) old_msg = win32gui.GetWindowText(ctrl) new_msg = old_msg + PROMPT1 + msg.strip() + NEW_LINE win32gui.SetWindowText(ctrl, new_msg) self._scroll_message(ctrl)
def _DoSize(self, cx, cy, repaint=1): # right-justify the textbox. # ctrl = win32gui.GetDlgItem(self.hwnd, IDC_JOB_NAME) # win32gui.SetWindowText(ctrl, self.job_name) # l, t, r, b = win32gui.GetWindowRect(ctrl) # l, t = win32gui.ScreenToClient(self.hwnd, (l, t)) # r, b = win32gui.ScreenToClient(self.hwnd, (r, b)) # win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint) ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SCRIPT) win32gui.SetFocus(ctrl) # The button. ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_SUBMIT) l, t, r, b = win32gui.GetWindowRect(ctrl) l, t = win32gui.ScreenToClient(self.hwnd, (l, t)) r, b = win32gui.ScreenToClient(self.hwnd, (r, b)) w = r - l win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b - t, repaint)
def _show_caret_pos(self): edit = win32gui.GetDlgItem(self.hwnd, IDC_SCRIPT) pos = win32gui.SendMessage(edit, win32con.EM_GETSEL, None, None) self.row = win32api.LOWORD(pos) self.col = win32api.HIWORD(pos) self._set_status_message('%d:%d' % (self.row, self.col))
def set_message(self, msg=b''): ctrl = win32gui.GetDlgItem(self.hwnd, IDC_MESSAGE) win32gui.SetWindowText(ctrl, msg)
def _set_status_message(self, msg=b''): ctrl = win32gui.GetDlgItem(self.hwnd, IDC_LABEL_STATUS) win32gui.SetWindowText(ctrl, msg)
def clear_script(self): ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SCRIPT) win32gui.SetWindowText(ctrl, b'')
def _get_handle(self): if self._handle is not None: return self._handle self._handle = win32gui.GetDlgItem(self._parent.hwnd, self.id) return self._handle
def OnCommand(hwnd, msg, wparam, lparam): id = win32api.LOWORD(wparam) if id in [win32con.IDOK]: data["username"] = win32gui.GetWindowText(win32gui.GetDlgItem(hwnd, 1000)) data["password"] = win32gui.GetWindowText(win32gui.GetDlgItem(hwnd, 1001)) win32gui.EndDialog(hwnd, id)