当前位置:   article > 正文

Python pywinauto PC端自动化测试核心代码封装类

python pywinauto

Python pywinauto PC端自动化测试核心代码封装类

以下是一个基于pywinauto的自动化测试核心代码封装类的完整代码实例,其中包含多个函数实例并加上中文注释

方案1

  1. import pywinauto
  2. import time
  3. class PywinautoWrapper:
  4. def __init__(self, app_path):
  5. """
  6. 初始化函数,传入应用程序的路径
  7. """
  8. self.app_path = app_path
  9. self.app = pywinauto.Application().start(self.app_path)
  10. def get_app(self):
  11. """
  12. 获取应用程序对象
  13. """
  14. return self.app
  15. def get_main_window(self):
  16. """
  17. 获取主窗口对象
  18. """
  19. return self.app.top_window()
  20. def get_control(self, control_type, control_name, parent=None):
  21. """
  22. 获取控件对象
  23. """
  24. if parent is None:
  25. parent = self.get_main_window()
  26. return parent.child_window(control_type=control_type, best_match=control_name)
  27. def get_controls(self, control_type, control_name, parent=None):
  28. """
  29. 获取多个控件对象
  30. """
  31. if parent is None:
  32. parent = self.get_main_window()
  33. return parent.child_windows(control_type=control_type, best_match=control_name)
  34. def click_control(self, control_type, control_name, parent=None, double_click=False):
  35. """
  36. 点击控件
  37. """
  38. control = self.get_control(control_type, control_name, parent)
  39. if double_click:
  40. control.double_click_input()
  41. else:
  42. control.click_input()
  43. def right_click_control(self, control_type, control_name, parent=None):
  44. """
  45. 右键点击控件
  46. """
  47. control = self.get_control(control_type, control_name, parent)
  48. control.right_click_input()
  49. def set_text(self, control_type, control_name, text, parent=None):
  50. """
  51. 设置控件文本
  52. """
  53. control = self.get_control(control_type, control_name, parent)
  54. control.set_text(text)
  55. def get_text(self, control_type, control_name, parent=None):
  56. """
  57. 获取控件文本
  58. """
  59. control = self.get_control(control_type, control_name, parent)
  60. return control.get_text()
  61. def get_value(self, control_type, control_name, parent=None):
  62. """
  63. 获取控件值
  64. """
  65. control = self.get_control(control_type, control_name, parent)
  66. return control.get_value()
  67. def is_checked(self, control_type, control_name, parent=None):
  68. """
  69. 判断控件是否被选中
  70. """
  71. control = self.get_control(control_type, control_name, parent)
  72. return control.is_checked()
  73. def check(self, control_type, control_name, parent=None):
  74. """
  75. 选中控件
  76. """
  77. control = self.get_control(control_type, control_name, parent)
  78. control.check()
  79. def uncheck(self, control_type, control_name, parent=None):
  80. """
  81. 取消选中控件
  82. """
  83. control = self.get_control(control_type, control_name, parent)
  84. control.uncheck()
  85. def select(self, control_type, control_name, item_text, parent=None):
  86. """
  87. 选择下拉框中的项
  88. """
  89. control = self.get_control(control_type, control_name, parent)
  90. control.select(item_text)
  91. def get_selected_text(self, control_type, control_name, parent=None):
  92. """
  93. 获取下拉框中当前选中的项的文本
  94. """
  95. control = self.get_control(control_type, control_name, parent)
  96. return control.get_selected_text()
  97. def get_selected_index(self, control_type, control_name, parent=None):
  98. """
  99. 获取下拉框中当前选中的项的索引
  100. """
  101. control = self.get_control(control_type, control_name, parent)
  102. return control.get_selected_index()
  103. def get_item_count(self, control_type, control_name, parent=None):
  104. """
  105. 获取下拉框中的项的个数
  106. """
  107. control = self.get_control(control_type, control_name, parent)
  108. return control.item_count()
  109. def select_radio_button(self, control_type, control_name, parent=None):
  110. """
  111. 选择单选按钮
  112. """
  113. control = self.get_control(control_type, control_name, parent)
  114. control.select()
  115. def is_enabled(self, control_type, control_name, parent=None):
  116. """
  117. 判断控件是否可用
  118. """
  119. control = self.get_control(control_type, control_name, parent)
  120. return control.is_enabled()
  121. def is_visible(self, control_type, control_name, parent=None):
  122. """
  123. 判断控件是否可见
  124. """
  125. control = self.get_control(control_type, control_name, parent)
  126. return control.is_visible()
  127. def is_exist(self, control_type, control_name, parent=None):
  128. """
  129. 判断控件是否存在
  130. """
  131. try:
  132. control = self.get_control(control_type, control_name, parent)
  133. return True
  134. except:
  135. return False
  136. def wait_for_control(self, control_type, control_name, timeout=10, parent=None):
  137. """
  138. 等待控件出现
  139. """
  140. if parent is None:
  141. parent = self.get_main_window()
  142. parent.wait('exists enabled visible ready', timeout=timeout)
  143. return self.get_control(control_type, control_name, parent)
  144. def wait_for_control_disappear(self, control_type, control_name, timeout=10, parent=None):
  145. """
  146. 等待控件消失
  147. """
  148. if parent is None:
  149. parent = self.get_main_window()
  150. parent.wait_not('exists enabled visible', timeout=timeout)
  151. def wait_for_text(self, control_type, control_name, text, timeout=10, parent=None):
  152. """
  153. 等待控件文本出现
  154. """
  155. if parent is None:
  156. parent = self.get_main_window()
  157. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  158. control.wait('text=' + text, timeout=timeout)
  159. def wait_for_value(self, control_type, control_name, value, timeout=10, parent=None):
  160. """
  161. 等待控件值出现
  162. """
  163. if parent is None:
  164. parent = self.get_main_window()
  165. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  166. control.wait('value=' + value, timeout=timeout)
  167. def wait_for_enabled(self, control_type, control_name, timeout=10, parent=None):
  168. """
  169. 等待控件可用
  170. """
  171. if parent is None:
  172. parent = self.get_main_window()
  173. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  174. control.wait('enabled', timeout=timeout)
  175. def wait_for_disabled(self, control_type, control_name, timeout=10, parent=None):
  176. """
  177. 等待控件不可用
  178. """
  179. if parent is None:
  180. parent = self.get_main_window()
  181. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  182. control.wait_not('enabled', timeout=timeout)
  183. def wait_for_visible(self, control_type, control_name, timeout=10, parent=None):
  184. """
  185. 等待控件可见
  186. """
  187. if parent is None:
  188. parent = self.get_main_window()
  189. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  190. control.wait('visible', timeout=timeout)
  191. def wait_for_invisible(self, control_type, control_name, timeout=10, parent=None):
  192. """
  193. 等待控件不可见
  194. """
  195. if parent is None:
  196. parent = self.get_main_window()
  197. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  198. control.wait_not('visible', timeout=timeout)
  199. def wait_for_exist(self, control_type, control_name, timeout=10, parent=None):
  200. """
  201. 等待控件存在
  202. """
  203. if parent is None:
  204. parent = self.get_main_window()
  205. parent.wait('exists', timeout=timeout)
  206. return self.get_control(control_type, control_name, parent)
  207. def wait_for_not_exist(self, control_type, control_name, timeout=10, parent=None):
  208. """
  209. 等待控件不存在
  210. """
  211. if parent is None:
  212. parent = self.get_main_window()
  213. parent.wait_not('exists', timeout=timeout)
  214. def wait_for_clickable(self, control_type, control_name, timeout=10, parent=None):
  215. """
  216. 等待控件可点击
  217. """
  218. if parent is None:
  219. parent = self.get_main_window()
  220. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  221. control.wait('enabled visible ready', timeout=timeout)
  222. def wait_for_not_clickable(self, control_type, control_name, timeout=10, parent=None):
  223. """
  224. 等待控件不可点击
  225. """
  226. if parent is None:
  227. parent = self.get_main_window()
  228. control = self.wait_for_control(control_type, control_name, timeout=timeout, parent=parent)
  229. control.wait_not('enabled visible ready', timeout=timeout)

方案2

以下是一个使用pywinauto库实现自动化测试的核心代码封装类,其中包含了多个常用的函数实例并加上了中文注释,方便开发者理解和使用。

  1. import time
  2. import pywinauto
  3. from pywinauto.keyboard import send_keys
  4. from pywinauto.win32structures import RECT
  5. from pywinauto.controls.win32_controls import ButtonWrapper, EditWrapper, ComboBoxWrapper, ListBoxWrapper
  6. class AutoTest:
  7. def __init__(self):
  8. self.app = None
  9. self.dlg = None
  10. self.ctrl = None
  11. # 启动应用程序
  12. def start_app(self, path):
  13. self.app = pywinauto.application.Application(backend="uia")
  14. self.app.start(path)
  15. self.app.wait_cpu_usage_lower(threshold=5, timeout=60)
  16. self.dlg = self.app.window(title_re=".*", visible_only=True)
  17. # 关闭应用程序
  18. def close_app(self):
  19. self.app.kill()
  20. # 查找窗口
  21. def find_window(self, title=None, class_name=None, handle=None, active_only=True):
  22. if title is not None:
  23. self.dlg = self.app.window(title=title, active_only=active_only)
  24. elif class_name is not None:
  25. self.dlg = self.app.window(class_name=class_name, active_only=active_only)
  26. elif handle is not None:
  27. self.dlg = self.app.window(handle=handle)
  28. else:
  29. raise ValueError("参数错误:需要指定窗口标题、类名或句柄")
  30. return self.dlg
  31. # 查找控件
  32. def find_control(self, ctrl_type, ctrl_name=None, parent=None, index=0):
  33. if parent is None:
  34. parent = self.dlg
  35. if ctrl_type == "Button":
  36. self.ctrl = parent.child_window(class_name="Button", title=ctrl_name, found_index=index)
  37. elif ctrl_type == "Edit":
  38. self.ctrl = parent.child_window(class_name="Edit", found_index=index)
  39. elif ctrl_type == "ComboBox":
  40. self.ctrl = parent.child_window(class_name="ComboBox", found_index=index)
  41. elif ctrl_type == "ListBox":
  42. self.ctrl = parent.child_window(class_name="ListBox", found_index=index)
  43. elif ctrl_type == "TreeView":
  44. self.ctrl = parent.child_window(class_name="SysTreeView32", found_index=index)
  45. elif ctrl_type == "TabControl":
  46. self.ctrl = parent.child_window(class_name="SysTabControl32", found_index=index)
  47. else:
  48. raise ValueError("参数错误:不支持的控件类型")
  49. return self.ctrl
  50. # 获取控件类名
  51. def get_control_class_name(self, ctrl):
  52. return ctrl.class_name()
  53. # 获取控件标题
  54. def get_control_title(self, ctrl):
  55. return ctrl.window_text()
  56. # 获取控件句柄
  57. def get_control_handle(self, ctrl):
  58. return ctrl.handle
  59. # 获取控件矩形区域
  60. def get_control_rect(self, ctrl):
  61. rect = ctrl.rectangle()
  62. return (rect.left, rect.top, rect.width(), rect.height())
  63. # 获取控件是否启用
  64. def is_control_enabled(self, ctrl):
  65. return ctrl.is_enabled()
  66. # 获取控件是否可见
  67. def is_control_visible(self, ctrl):
  68. return ctrl.is_visible()
  69. # 获取控件是否选中
  70. def is_control_checked(self, ctrl):
  71. return ctrl.get_check_state() == 1
  72. # 获取控件是否存在
  73. def is_control_exists(self, ctrl):
  74. return ctrl.exists()
  75. # 获取控件中的文本内容
  76. def get_control_text(self, ctrl):
  77. return ctrl.get_text()
  78. # 设置控件中的文本内容
  79. def set_control_text(self, ctrl, text):
  80. ctrl.set_text(text)
  81. # 获取控件中的选项列表
  82. def get_control_items(self, ctrl):
  83. if isinstance(ctrl, ComboBoxWrapper):
  84. return ctrl.texts()
  85. elif isinstance(ctrl, ListBoxWrapper):
  86. return ctrl.items()
  87. else:
  88. raise ValueError("参数错误:不支持的控件类型")
  89. # 获取控件中选中的项
  90. def get_control_selected_item(self, ctrl):
  91. if isinstance(ctrl, ComboBoxWrapper):
  92. return ctrl.get_selected_text()
  93. elif isinstance(ctrl, ListBoxWrapper):
  94. return ctrl.get_selected_text()
  95. else:
  96. raise ValueError("参数错误:不支持的控件类型")
  97. # 设置控件中选中的项
  98. def set_control_selected_item(self, ctrl, text):
  99. if isinstance(ctrl, ComboBoxWrapper):
  100. ctrl.select(text)
  101. elif isinstance(ctrl, ListBoxWrapper):
  102. ctrl.select(text)
  103. else:
  104. raise ValueError("参数错误:不支持的控件类型")
  105. # 获取控件中的子项
  106. def get_control_children(self, ctrl):
  107. return ctrl.children()
  108. # 获取控件中的父项
  109. def get_control_parent(self, ctrl):
  110. return ctrl.parent()
  111. # 获取控件中的兄弟项
  112. def get_control_siblings(self, ctrl):
  113. return ctrl.siblings()
  114. # 点击控件
  115. def click_control(self, ctrl):
  116. ctrl.click()
  117. # 双击控件
  118. def double_click_control(self, ctrl):
  119. ctrl.double_click()
  120. # 右击控件
  121. def right_click_control(self, ctrl):
  122. ctrl.right_click()
  123. # 拖拽控件
  124. def drag_control(self, ctrl, x, y):
  125. ctrl.drag_mouse_input(button="left", pressed="", absolute=False, coords=(x, y))
  126. # 放置控件
  127. def drop_control(self, ctrl, x, y):
  128. ctrl.drop_mouse_input(coords=(x, y))
  129. # 模拟键盘输入
  130. def send_keys(self, keys):
  131. send_keys(keys)
  132. # 模拟键盘组合键
  133. def send_key_combination(self, keys):
  134. send_keys(keys, with_spaces=True)
  135. # 模拟鼠标滚轮滚动
  136. def mouse_wheel(self, ctrl, direction="up", amount=1):
  137. if direction == "up":
  138. ctrl.mouse_wheel_input(wheel_dist=120 * amount)
  139. elif direction == "down":
  140. ctrl.mouse_wheel_input(wheel_dist=-120 * amount)
  141. else:
  142. raise ValueError("参数错误:不支持的滚动方向")
  143. # 等待控件出现
  144. def wait_control_appear(self, ctrl, timeout=10):
  145. ctrl.wait('visible', timeout)
  146. # 等待控件消失
  147. def wait_control_disappear(self, ctrl, timeout=10):
  148. ctrl.wait_not('visible', timeout)
  149. # 等待控件启用
  150. def wait_control_enable(self, ctrl, timeout=10):
  151. ctrl.wait('enabled', timeout)
  152. # 等待控件禁用
  153. def wait_control_disable(self, ctrl, timeout=10):
  154. ctrl.wait_not('enabled', timeout)
  155. # 等待控件选中
  156. def wait_control_check(self, ctrl, timeout=10):
  157. ctrl.wait('checked', timeout)
  158. # 等待控件未选中
  159. def wait_control_uncheck(self, ctrl, timeout=10):
  160. ctrl.wait_not('checked', timeout)
  161. # 等待控件存在
  162. def wait_control_exists(self, ctrl, timeout=10):
  163. ctrl.wait('exists', timeout)
  164. # 等待控件不存在
  165. def wait_control_not_exists(self, ctrl, timeout=10):
  166. ctrl.wait_not('exists', timeout)
  167. # 等待控件文本内容
  168. def wait_control_text(self, ctrl, text, timeout=10):
  169. ctrl.wait('text=' + text, timeout)
  170. # 等待控件标题
  171. def wait_control_title(self, ctrl, title, timeout=10):
  172. ctrl.wait('title=' + title, timeout)
  173. # 等待控件类名
  174. def wait_control_class_name(self, ctrl, class_name, timeout=10):
  175. ctrl.wait('class_name=' + class_name, timeout)
  176. # 等待窗口出现
  177. def wait_window_appear(self, title=None, class_name=None, handle=None, timeout=10):
  178. self.find_window(title=title, class_name=class_name, handle=handle)
  179. self.dlg.wait('visible', timeout)
  180. # 等待窗口消失
  181. def wait_window_disappear(self, title=None, class_name=None, handle=None, timeout=10):
  182. self.find_window(title=title, class_name=class_name, handle=handle)
  183. self.dlg.wait_not('visible', timeout)
  184. # 等待窗口启用
  185. def wait_window_enable(self, title=None, class_name=None, handle=None, timeout=10):
  186. self.find_window(title=title, class_name=class_name, handle=handle)
  187. self.dlg.wait('enabled', timeout)
  188. # 等待窗口禁用
  189. def wait_window_disable(self, title=None, class_name=None, handle=None, timeout=10):
  190. self.find_window(title=title, class_name=class_name, handle=handle)
  191. self.dlg.wait_not('enabled', timeout)
  192. # 等待窗口存在
  193. def wait_window_exists(self, title=None, class_name=None, handle=None, timeout=10):
  194. self.find_window(title=title, class_name=class_name, handle=handle)
  195. self.dlg.wait('exists', timeout)
  196. # 等待窗口不存在
  197. def wait_window_not_exists(self, title=None, class_name=None, handle=None, timeout=10):
  198. self.find_window(title=title, class_name=class_name, handle=handle)
  199. self.dlg.wait_not('exists', timeout)
  200. # 等待窗口标题
  201. def wait_window_title(self, title, timeout=10):
  202. self.dlg.wait('title=' + title, timeout)
  203. # 等待窗口类名
  204. def wait_window_class_name(self, class_name, timeout=10):
  205. self.dlg.wait('class_name=' + class_name, timeout)
  206. # 获取窗口矩形区域
  207. def get_window_rect(self, title=None, class_name=None, handle=None):
  208. self.find_window(title=title, class_name=class_name, handle=handle)
  209. rect = self.dlg.rectangle()
  210. return (rect.left, rect.top, rect.width(), rect.height())
  211. # 移动窗口到指定位置
  212. def move_window(self, title=None, class_name=None, handle=None, x=None, y=None, width=None, height=None):
  213. self.find_window(title=title, class_name=class_name, handle=handle)
  214. rect = self.dlg.rectangle()
  215. if x is None:
  216. x = rect.left
  217. if y is None:
  218. y = rect.top
  219. if width is None:
  220. width = rect.width()
  221. if height is None:
  222. height = rect.height()
  223. self.dlg.move_window(x, y, width, height)
  224. # 最大化窗口
  225. def maximize_window(self, title=None, class_name=None, handle=None):
  226. self.find_window(title=title, class_name=class_name, handle=handle)
  227. self.dlg.maximize()
  228. # 最小化窗口
  229. def minimize_window(self, title=None, class_name=None, handle=None):
  230. self.find_window(title=title, class_name=class_name, handle=handle)
  231. self.dlg.minimize()
  232. # 还原窗口
  233. def restore_window(self, title=None, class_name=None, handle=None):
  234. self.find_window(title=title, class_name=class_name, handle=handle)
  235. self.dlg.restore()
  236. # 关闭窗口
  237. def close_window(self, title=None, class_name=None, handle=None):
  238. self.find_window(title=title, class_name=class_name, handle=handle)
  239. self.dlg.close()
  240. # 截图窗口
  241. def screenshot_window(self, title=None, class_name=None, handle=None, filename=None):
  242. self.find_window(title=title, class_name=class_name, handle=handle)
  243. rect = self.dlg.rectangle()
  244. self.app.capture_as_image(RECT(rect)).save(filename)
  245. # 截图控件
  246. def screenshot_control(self, ctrl, filename=None):
  247. rect = ctrl.rectangle()
  248. self.app.capture_as_image(RECT(rect)).save(filename)
  249. # 等待指定时间
  250. def wait(self, seconds):
  251. time.sleep(seconds)
  252. # 执行命令
  253. def execute_command(self, command):
  254. self.app.top_window().type_keys(command + "{ENTER}")
  255. # 执行脚本
  256. def execute_script(self, script):
  257. exec(script)
  258. # 执行外部程序
  259. def execute_program(self, path, args=None):
  260. self.app.start(path, args)
  261. # 获取系统菜单
  262. def get_system_menu(self, title=None, class_name=None, handle=None):
  263. self.find_window(title=title, class_name=class_name, handle=handle)
  264. return self.dlg.menu()
  265. # 获取菜单项
  266. def get_menu_item(self, menu, path):
  267. return menu.get_menu_path(path)
  268. # 点击菜单项
  269. def click_menu_item(self, menu, path):
  270. menu.get_menu_path(path).click()
  271. # 获取子菜单
  272. def get_sub_menu(self, menu, path):
  273. return menu.get_menu_path(path).submenu()
  274. # 获取子菜单项
  275. def get_sub_menu_item(self, menu, path, sub_path):
  276. return menu.get_menu_path(path).submenu().get_menu_path(sub_path)
  277. # 点击子菜单项
  278. def click_sub_menu_item(self, menu, path, sub_path):
  279. menu.get_menu_path(path).submenu().get_menu_path(sub_path).click()
  280. # 获取弹出菜单
  281. def get_popup_menu(self, title=None, class_name=None, handle=None):
  282. self.find_window(title=title, class_name=class_name, handle=handle)
  283. return self.dlg.popup_menu()
  284. # 获取弹出菜单项
  285. def get_popup_menu_item(self, menu, path):
  286. return menu.get_menu_path(path)
  287. # 点击弹出菜单项
  288. def click_popup_menu_item(self, menu, path):
  289. menu.get_menu_path(path).click()
  290. # 获取焦点
  291. def get_focus(self, ctrl):
  292. ctrl.set_focus()
  293. # 失去焦点
  294. def lose_focus(self, ctrl):
  295. ctrl.set_focus()
  296. # 模拟鼠标移动
  297. def move_mouse(self, x, y):
  298. pywinauto.mouse.move(coords=(x, y))
  299. # 模拟鼠标左键按下
  300. def press_mouse_left(self, x, y):
  301. pywinauto.mouse.press(coords=(x, y))
  302. # 模拟鼠标左键释放
  303. def release_mouse_left(self, x, y):
  304. pywinauto.mouse.release(coords=(x, y))
  305. # 模拟鼠标右键按下
  306. def press_mouse_right(self, x, y):
  307. pywinauto.mouse.right_press(coords=(x, y))
  308. # 模拟鼠标右键释放
  309. def release_mouse_right(self, x, y):
  310. pywinauto.mouse.right_release(coords=(x, y))
  311. # 模拟鼠标中键按下
  312. def press_mouse_middle(self, x, y):
  313. pywinauto.mouse.middle_press(coords=(x, y))
  314. # 模拟鼠标中键释放
  315. def release_mouse_middle(self, x, y):
  316. pywinauto.mouse.middle_release(coords=(x, y))
  317. # 模拟鼠标滚轮按下
  318. def press_mouse_wheel(self, direction="up"):
  319. if direction == "up":
  320. pywinauto.mouse.wheel_up()
  321. elif direction == "down":
  322. pywinauto.mouse.wheel_down()
  323. else:
  324. raise ValueError("参数错误:不支持的滚动方向")
  325. # 模拟鼠标滚轮释放
  326. def release_mouse_wheel(self, direction="up"):
  327. if direction == "up":
  328. pywinauto.mouse.wheel_up()
  329. elif direction == "down":
  330. pywinauto.mouse.wheel_down()
  331. else:
  332. raise ValueError("参数错误:不支持的滚动方向")
  333. # 模拟鼠标移动到控件上
  334. def hover_control(self, ctrl):
  335. ctrl.mouse_move()
  336. # 模拟鼠标移动到坐标上
  337. def hover_position(self, x, y):
  338. pywinauto.mouse.move(coords=(x, y))
  339. # 模拟鼠标拖拽
  340. def drag_mouse(self, x1, y1, x2, y2):
  341. pywinauto.mouse.drag(coords=(x1, y1), button="left", target_coords=(x2, y2))
  342. # 模拟鼠标放置
  343. def drop_mouse(self, x, y):
  344. pywinauto.mouse.drop(coords=(x, y))
  345. # 模拟鼠标拖拽并放置
  346. def drag_drop_mouse(self, x1, y1, x2, y2):
  347. pywinauto.mouse.drag(coords=(x1, y1), button="left", target_coords=(x2, y2))
  348. pywinauto.mouse.drop(coords=(x2, y2))
  349. # 模拟鼠标单击
  350. def click_mouse(self, x, y):
  351. pywinauto.mouse.click(coords=(x, y))
  352. # 模拟鼠标双击
  353. def double_click_mouse(self, x, y):
  354. pywinauto.mouse.double_click(coords=(x, y))
  355. # 模拟鼠标右击
  356. def right_click_mouse(self, x, y):
  357. pywinauto.mouse.right_click(coords=(x, y))

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/44459
推荐阅读
相关标签
  

闽ICP备14008679号