办公纸自动化软件(python)

传送门:5分钟,教你做个自动化软件拿来办公、刷副本、回微信 | 源码公开,开箱即用_哔哩哔哩_bilibili

程序可以跑一些,简单重复性的工作,比如自动回微信,视频 站自动点赞之类的!

自己跑了一下,的确很好用!但是滑轮没用明白,如果有大神希望指点一二

可以私信联系我

最近两天没更flask,要学习了!

代码如下,文末有操作手册

直接下载源文件:waterRPA.rar – 蓝奏云


  1. import pyautogui
  2. import time
  3. import xlrd
  4. import pyperclip
  5. #定义鼠标事件
  6. #pyautogui库其他用法 https://blog.csdn.net/qingfengxd1/article/details/108270159
  7. def mouseClick(clickTimes,lOrR,img,reTry):
  8. if reTry == 1:
  9. while True:
  10. location=pyautogui.locateCenterOnScreen(img,confidence=0.9)
  11. if location is not None:
  12. pyautogui.click(location.x,location.y,clicks=clickTimes,interval=0.2,duration=0.2,button=lOrR)
  13. break
  14. print("未找到匹配图片,0.1秒后重试")
  15. time.sleep(0.1)
  16. elif reTry == -1:
  17. while True:
  18. location=pyautogui.locateCenterOnScreen(img,confidence=0.9)
  19. if location is not None:
  20. pyautogui.click(location.x,location.y,clicks=clickTimes,interval=0.2,duration=0.2,button=lOrR)
  21. time.sleep(0.1)
  22. elif reTry > 1:
  23. i = 1
  24. while i
  25. location=pyautogui.locateCenterOnScreen(img,confidence=0.9)
  26. if location is not None:
  27. pyautogui.click(location.x,location.y,clicks=clickTimes,interval=0.2,duration=0.2,button=lOrR)
  28. print("重复")
  29. i += 1
  30. time.sleep(0.1)
  31. # 数据检查
  32. # cmdType.value 1.0 左键单击 2.0 左键双击 3.0 右键单击 4.0 输入 5.0 等待 6.0 滚轮
  33. # ctype 空:0
  34. # 字符串:1
  35. # 数字:2
  36. # 日期:3
  37. # 布尔:4
  38. # error:5
  39. def dataCheck(sheet1):
  40. checkCmd = True
  41. #行数检查
  42. if sheet1.nrows
  43. print("没数据啊哥")
  44. checkCmd = False
  45. #每行数据检查
  46. i = 1
  47. while i
  48. # 第1列 操作类型检查
  49. cmdType = sheet1.row(i)[0]
  50. if cmdType.ctype != 2 or (cmdType.value != 1.0 and cmdType.value != 2.0 and cmdType.value != 3.0
  51. and cmdType.value != 4.0 and cmdType.value != 5.0 and cmdType.value != 6.0):
  52. print('第',i+1,"行,第1列数据有毛病")
  53. checkCmd = False
  54. # 第2列 内容检查
  55. cmdValue = sheet1.row(i)[1]
  56. # 读图点击类型指令,内容必须为字符串类型
  57. if cmdType.value ==1.0 or cmdType.value == 2.0 or cmdType.value == 3.0:
  58. if cmdValue.ctype != 1:
  59. print('第',i+1,"行,第2列数据有毛病")
  60. checkCmd = False
  61. # 输入类型,内容不能为空
  62. if cmdType.value == 4.0:
  63. if cmdValue.ctype == 0:
  64. print('第',i+1,"行,第2列数据有毛病")
  65. checkCmd = False
  66. # 等待类型,内容必须为数字
  67. if cmdType.value == 5.0:
  68. if cmdValue.ctype != 2:
  69. print('第',i+1,"行,第2列数据有毛病")
  70. checkCmd = False
  71. # 滚轮事件,内容必须为数字
  72. if cmdType.value == 6.0:
  73. if cmdValue.ctype != 2:
  74. print('第',i+1,"行,第2列数据有毛病")
  75. checkCmd = False
  76. i += 1
  77. return checkCmd
  78. #任务
  79. def mainWork(img):
  80. i = 1
  81. while i
  82. #取本行指令的操作类型
  83. cmdType = sheet1.row(i)[0]
  84. if cmdType.value == 1.0:
  85. #取图片名称
  86. img = sheet1.row(i)[1].value
  87. reTry = 1
  88. if sheet1.row(i)[2].ctype == 2 and sheet1.row(i)[2].value != 0:
  89. reTry = sheet1.row(i)[2].value
  90. mouseClick(1,"left",img,reTry)
  91. print("单击左键",img)
  92. #2代表双击左键
  93. elif cmdType.value == 2.0:
  94. #取图片名称
  95. img = sheet1.row(i)[1].value
  96. #取重试次数
  97. reTry = 1
  98. if sheet1.row(i)[2].ctype == 2 and sheet1.row(i)[2].value != 0:
  99. reTry = sheet1.row(i)[2].value
  100. mouseClick(2,"left",img,reTry)
  101. print("双击左键",img)
  102. #3代表右键
  103. elif cmdType.value == 3.0:
  104. #取图片名称
  105. img = sheet1.row(i)[1].value
  106. #取重试次数
  107. reTry = 1
  108. if sheet1.row(i)[2].ctype == 2 and sheet1.row(i)[2].value != 0:
  109. reTry = sheet1.row(i)[2].value
  110. mouseClick(1,"right",img,reTry)
  111. print("右键",img)
  112. #4代表输入
  113. elif cmdType.value == 4.0:
  114. inputValue = sheet1.row(i)[1].value
  115. pyperclip.copy(inputValue)
  116. pyautogui.hotkey('ctrl','v')
  117. time.sleep(0.5)
  118. print("输入:",inputValue)
  119. #5代表等待
  120. elif cmdType.value == 5.0:
  121. #取图片名称
  122. waitTime = sheet1.row(i)[1].value
  123. time.sleep(waitTime)
  124. print("等待",waitTime,"秒")
  125. #6代表滚轮
  126. elif cmdType.value == 6.0:
  127. #取图片名称
  128. scroll = sheet1.row(i)[1].value
  129. pyautogui.scroll(int(scroll))
  130. print("滚轮滑动",int(scroll),"距离")
  131. i += 1
  132. if __name__ == '__main__':
  133. file = 'cmd.xls'
  134. #打开文件
  135. wb = xlrd.open_workbook(filename=file)
  136. #通过索引获取表格sheet页
  137. sheet1 = wb.sheet_by_index(0)
  138. print('欢迎使用不高兴就喝水牌RPA~')
  139. #数据检查
  140. checkCmd = dataCheck(sheet1)
  141. if checkCmd:
  142. key=input('选择功能: 1.做一次 2.循环到死 n')
  143. if key=='1':
  144. #循环拿出每一行指令
  145. 声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年10月5日
下一篇 2022年10月6日

相关推荐