@@ -781,6 +781,7 @@ def _uc_gui_click_captcha(
781781    )
782782    with  gui_lock :  # Prevent issues with multiple processes 
783783        needs_switch  =  False 
784+         width_ratio  =  1.0 
784785        is_in_frame  =  js_utils .is_in_frame (driver )
785786        if  is_in_frame  and  driver .is_element_present ("#challenge-stage" ):
786787            driver .switch_to .parent_frame ()
@@ -791,6 +792,20 @@ def _uc_gui_click_captcha(
791792            page_actions .switch_to_window (
792793                driver , driver .current_window_handle , 2 , uc_lock = False 
793794            )
795+         if  IS_WINDOWS :
796+             window_rect  =  driver .get_window_rect ()
797+             width  =  window_rect ["width" ]
798+             height  =  window_rect ["height" ]
799+             win_x  =  window_rect ["x" ]
800+             win_y  =  window_rect ["y" ]
801+             scr_width  =  pyautogui .size ().width 
802+             driver .maximize_window ()
803+             win_width  =  driver .get_window_size ()["width" ]
804+             width_ratio  =  round (float (scr_width ) /  float (win_width ), 2 ) +  0.01 
805+             if  width_ratio  <  0.45  or  width_ratio  >  2.55 :
806+                 width_ratio  =  1.01 
807+             driver .minimize_window ()
808+             driver .set_window_rect (win_x , win_y , width , height )
794809        if  ctype  ==  "cf_t" :
795810            if  (
796811                driver .is_element_present (".cf-turnstile-wrapper iframe" )
@@ -1015,6 +1030,18 @@ def _uc_gui_handle_captcha(
10151030            page_actions .switch_to_window (
10161031                driver , driver .current_window_handle , 2 , uc_lock = False 
10171032            )
1033+         if  IS_WINDOWS  and  hasattr (pyautogui , "getActiveWindowTitle" ):
1034+             py_a_g_title  =  pyautogui .getActiveWindowTitle ()
1035+             window_title  =  driver .title 
1036+             if  not  py_a_g_title .startswith (window_title ):
1037+                 window_rect  =  driver .get_window_rect ()
1038+                 width  =  window_rect ["width" ]
1039+                 height  =  window_rect ["height" ]
1040+                 win_x  =  window_rect ["x" ]
1041+                 win_y  =  window_rect ["y" ]
1042+                 driver .minimize_window ()
1043+                 driver .set_window_rect (win_x , win_y , width , height )
1044+                 time .sleep (0.33 )
10181045        if  ctype  ==  "cf_t" :
10191046            if  (
10201047                driver .is_element_present (".cf-turnstile-wrapper iframe" )
0 commit comments