@@ -121,6 +121,9 @@ def buildTag(name, value):
121121def scanRows (rows ):
122122 global art_id
123123 global saved
124+ rows = list (rows )
125+ if len (rows )< 1 :
126+ return True
124127 art_center_x = first_art_x + (art_width + art_gap_x - 0.5 )* 0 + art_width / 2
125128 art_center_y = first_art_y + (art_height + art_gap_y - 0.5 )* rows [0 ]+ art_height / 2
126129 mouse .move (left + art_center_x , top + art_center_y )
@@ -196,7 +199,7 @@ def scrollToRow(target_row, max_scrolls=20):
196199
197200if hwnd is None or hwnd == 0 :
198201 input ('未找到在运行的原神' )
199- exit ()
202+ sys . exit (0 )
200203
201204w ,h = win32gui .GetClientRect (hwnd )[2 :]
202205
@@ -205,11 +208,12 @@ def scrollToRow(target_row, max_scrolls=20):
205208
206209if w == 0 or h == 0 :
207210 print ("不支持独占全屏模式" )
208- exit ()
211+ w , h = eval (input ("如果要强行继续运行,请输入原神的分辨率,格式是\" 宽,高\" ,例如 1920,1080(不用引号):" ))
212+ left , top = 0 , 0
209213
210214if abs (w / h - 2560 / 1440 )> 0.05 :
211- print ('请将原神设定成16 :9分辨率' )
212- exit ()
215+ print ('只支持16 :9分辨率' )
216+ sys . exit (0 )
213217
214218
215219# initialization
@@ -276,16 +280,21 @@ def to_stop():
276280print ('对齐完成,即将开始扫描' )
277281time .sleep (0.5 )
278282start_row = 0
279- while True :
280- if stopped or not scanRows (rows = range (start_row , art_rows )) or start_row != 0 :
281- break
282- start_row = 5 - scrollToRow (5 , max_scrolls = 20 )
283+ try :
284+ while True :
285+ if stopped or not scanRows (rows = range (start_row , art_rows )) or start_row != 0 :
286+ break
287+ start_row = 5 - scrollToRow (5 , max_scrolls = 20 )
288+ if start_row == 5 :
289+ break
290+ except Exception as e :
291+ print (f"因为\" { e } \" 而意外停止扫描,将保存已扫描的圣遗物信息" )
283292print ()
284293if saved :
285294 with open ('artifacts.genshinart.json' , "wb" ) as f :
286295 s = json .dumps (result , ensure_ascii = False )
287296 f .write (s .encode ('utf-8' ))
288297 print ('总计扫描了{}个圣遗物,保存了{}个到artifacts.genshinart.json,未保存的则为识别结果无法理解,请到artifacts路径中查看' .format (art_id , saved ))
289298else :
290- print ('总计扫描了{}个圣遗物,未保存任何圣遗物,未保存的则为识别结果无法理解,请到artifacts路径中查看' .format (art_id , saved ))
299+ print ('总计扫描了{}个圣遗物,未保存任何圣遗物,未保存的则为识别结果无法理解,请到artifacts路径中查看' .format (art_id ))
291300input ('已完成,按回车退出' )
0 commit comments