浏览代码

fix:有色将自动点击的逻辑打开,然后调整了钢联和有色的最大最小x/y的位置

Roc 1 年之前
父节点
当前提交
396ff3137e
共有 2 个文件被更改,包括 26 次插入14 次删除
  1. 2 2
      rpa_mysteel_refresh.py
  2. 24 12
      rpa_smm_refresh.py

+ 2 - 2
rpa_mysteel_refresh.py

@@ -30,9 +30,9 @@ get_data_timeout_time = 30
 
 # 随机点击的按钮范围
 pointMinX = 200
-pointMaxX = 700
+pointMaxX = 650
 pointMinY = 300
-pointMaxY = 600
+pointMaxY = 550
 
 @hug.get('/mysteel_chemical/server')
 def mysteel_chemical_server():

+ 24 - 12
rpa_smm_refresh.py

@@ -16,13 +16,15 @@ import datetime
 hug.API(__name__).http.output_format = hug.output_format.json
 
 exePath = r"C:\Program Files (x86)\Kingsoft\WPS Office\11.8.2.12085\office6\et"
+# exePath = exePath = r"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"
+# exePath = exePath = r"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
 
 @hug.get('/smm_chemical/server')
 def smm_server():
     return 1
 
 # 顶部有色按钮的x,y位置
-smm_button_x = 897
+smm_button_x = 642
 smm_button_y = 53
 
 # 中间更新数据下拉框按钮的x,y位置
@@ -36,6 +38,13 @@ smm_refresh_button_y = 178
 # 超时时间,默认15s
 timeout_time = 15
 
+
+# 随机点击的按钮范围
+pointMinX = 200
+pointMaxX = 650
+pointMinY = 300
+pointMaxY = 550
+
 @hug.get('/smm_chemical/refresh')
 def smm_refresh(file_path):
     screen_width, screen_height = pyautogui.size()
@@ -103,16 +112,16 @@ def smm_refresh(file_path):
                 # autoit.win_move_by_handle(hwnd, 0, 0, 1920, 1080)
 
             # 等待自动刷新结束
-            time.sleep(15)
+            #time.sleep(15)
 
             # 保存
-            pyautogui.hotkey('ctrl', 's')
-            time.sleep(1)
+            #pyautogui.hotkey('ctrl', 's')
+            #time.sleep(1)
 
             # 关闭当前excel
-            pyautogui.hotkey('ctrl', 'w')
+            #pyautogui.hotkey('ctrl', 'w')
 
-            return True
+            #return True
 
             # 屏幕最大化
             hwnd = win32gui.GetForegroundWindow()
@@ -122,11 +131,12 @@ def smm_refresh(file_path):
             # 随机2-3次点击 单元格区域
             r = random.randint(2, 3)
             for i in range(r):
-                point_x = random.randint(511, 1745)
-                point_y = random.randint(282, 791)
-                print("随机点击", i + 1, "下")
-                pyautogui.moveTo(point_x, point_y, 0.5)
+                pointX = random.randint(pointMinX, pointMaxX)
+                pointY = random.randint(pointMinY, pointMaxY)
+                print("随机点击", i + 1, "下", "点击X:", pointX, ";Y:", pointY)
+                pyautogui.moveTo(pointX, pointY, 0.5)
                 pyautogui.click()
+                time.sleep(1)
 
             # 随机停留几秒
             r = random.randint(1, 2)
@@ -154,11 +164,13 @@ def smm_refresh(file_path):
             pyautogui.click()
             time.sleep(0.5)
 
+            pointX = random.randint(pointMinX, pointMaxX)
+            pointY = random.randint(pointMinY, pointMaxY)
             # 点击完刷新按钮后,移开鼠标
-            pyautogui.moveTo(622, 300, 0.5)
+            pyautogui.moveTo(pointX, pointY, 0.5)
 
             # 等待刷新结束
-            time.sleep(10)
+            time.sleep(timeout_time)
 
             # 保存
             pyautogui.hotkey('ctrl', 's')