@@ -248,6 +248,7 @@ def click_with_options(self, hold_time, delay, up, down):
248248 pass
249249 self .ui .btn_start .setDisabled (False )
250250 self .ui .btn_stop .setDisabled (True )
251+ self .ui .btn_shortcut .setDisabled (False )
251252 return
252253
253254 def click (self , hold_time , up , down ):
@@ -262,11 +263,23 @@ def click_helper(self, hold_time, up, down):
262263
263264 def timer_countdown (self ):
264265 temp = self .click_timer
265- time .sleep (temp )
266- self .__stop_threads = True
266+ while True :
267+ time .sleep (1 )
268+ temp = temp - 1
269+ print (temp )
270+ if self .__stop_threads :
271+ temp = 0
272+ if temp <= 0 :
273+ self .__stop_threads = True
274+ break
275+
276+ def timer_sleep (self , delay ):
277+ target = time .perf_counter_ns () + delay * 1000
278+ while time .perf_counter_ns () < target :
279+ pass # precise timing
267280
268281 def start (self ):
269- self .ui .btn_shortcut .setEnabled ( False )
282+ self .ui .btn_shortcut .setDisabled ( True )
270283 self .ui .btn_start .setDisabled (True )
271284 self .ui .btn_stop .setDisabled (False )
272285 self .click_thread = threading .Thread (
@@ -278,10 +291,13 @@ def start(self):
278291
279292 def stop (self ):
280293 self .__stop_threads = True
281- self .click_thread .join ()
294+ try :
295+ self .click_thread .join ()
296+ except RuntimeError :
297+ pass
282298 self .ui .btn_start .setDisabled (False )
283299 self .ui .btn_stop .setDisabled (True )
284- self .ui .btn_shortcut .setEnabled ( True )
300+ self .ui .btn_shortcut .setDisabled ( False )
285301
286302 def update_vars (self ):
287303 try :
0 commit comments