
     fQ                        d dl Z d dlZ d dlZd dlmZmZmZ d dlZej        dk    r ed          	 e j	        j
                                         n# e$ r Y nw xY w	 dZdZdZeez   ZdZd	Zeez   Zd
ZdZeez   ZdZdZdZd ZdZd ZdZ G d de j                  Z G d de j                  Z  G d de j                  Z! G d de j                  Z"	  e#d ej$        D                       Z%e%&                    i dddddddddddd d!d"d#d"d$d"d%d	d&d'd(d)d*d+d,d-d.d/d0d/d1d/i d2d3d4d5d6d7d8d7d9d:d;d:d<d=d>d?d@dAdBdCdDd
dEd
dFdGdHdIdJdGdKdIdLdMi dNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`d_dad_dbd_dcdddedfdgdfdhdidjdi dkddldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddÓddœddǓddɓdd˓dd͓ddϓi ddѓddӓddՓddדddٓddۓddݓddߓddddddddddddddddddddd            e'd
d          D ]NZ(e j	        j
        )                    e j*        +                     e,e(                              e% e,e(          <   Od Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4d Z5ddZ6ddZ7d  Z8d Z9dS (      N)LEFTMIDDLERIGHTwin32zCThe pyautogui_win module should only be loaded on a Windows system.                   @   i   i   i   c            	           e Zd Zdej        j        fdej        j        fdej        j        fdej        j        fdej        j        fd ej        ej        j                  fgZ	dS )
MOUSEINPUTdxdy	mouseDatadwFlagstimedwExtraInfoN)
__name__
__module____qualname__ctypeswintypesLONGDWORDPOINTERULONG_fields_     [/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/pyautogui/_pyautogui_win.pyr   r   >   so        	v#$	v#$	fo+,	FO)*	&'	v'<==>HHHr!   r   c                       e Zd Zdej        j        fdej        j        fdej        j        fdej        j        fd ej        ej        j                  fgZ	dS )
KEYBDINPUTwVkwScanr   r   r   N)
r   r   r   r   r   WORDr   r   r   r   r    r!   r"   r$   r$   H   sb        	$%	&/&'	FO)*	&'	v'<==>HHHr!   r$   c                   `    e Zd Zdej        j        fdej        j        fdej        j        fgZdS )HARDWAREINPUTuMsgwParamLwParamHN)r   r   r   r   r   r   r'   r   r    r!   r"   r)   r)   Q   s<        	&'	FO()	FO)*HHHr!   r)   c                   \    e Zd Z G d dej                  ZdZdej        j        fdefgZ	dS )INPUTc                   $    e Zd ZdefdefdefgZdS )INPUT._ImikihiN)r   r   r   r   r$   r)   r   r    r!   r"   _Ir0   Y   s-        ::=!
r!   r4   )ityper5   N)
r   r   r   r   Unionr4   _anonymous_r   r   r   r    r!   r"   r.   r.   X   s\        
 
 
 
 
V\ 
 
 
 K	&'	b	HHHr!   r.   c                     g | ]}|d fS )Nr    ).0keys     r"   
<listcomp>r<   p   s    CCCdCCCr!   	backspacesuper[   tab	   	clear   enter   
returnshiftctrl   alt   pause   capslock   kana   hanguelhanguljunja   final   hanja   kanjiesc   escapeconvert   
nonconvert   accept   
modechange    spacepgup!   pgdn"   pageuppagedownend#   home$   left%   up&   right'   down(   select)   print*   execute+   prtsc,   prtscrprntscrnprintscreeninsert-   del.   deletehelp/   winwinleftwinright\   apps]   sleep_   num0`   num1a   num2b   num3c   num4d   num5e   num6f   num7g   num8h   num9i   multiplyj   addk   	separatorl   subtractm   decimaln   divideo   f1p   f2q   f3r   f4s   f5t   f6u   f7v   f8w   f9x   f10y   f11z   f12{   f13|   f14}   f15~   f16   f17   f18   f19   f20   f21   f22   f23   f24   numlock   
scrolllock   	shiftleft   
shiftright   ctrlleft   	ctrlright   altleft   altright   browserback   browserforward   browserrefresh   browserstop   browsersearch   browserfavorites   browserhome   
volumemute   
volumedown   volumeup   	nexttrack   	prevtrack   stop   	playpause   
launchmail   launchmediaselect         )
launchapp1
launchapp2c                    | t           vst           |          dS t          j        |           }	 t          t           |          d          \  }}|dz  df|dz  df|dz  p|dffD ]3\  }}|r,t          j        j                            |d	t          d	           4t          j        j                            |d	t          d	           |dz  p|df|dz  df|dz  dffD ]3\  }}|r,t          j        j                            |d	t          d	           4dS )
a}  Performs a keyboard key press without the release. This will put that
    key in a held down state.

    NOTE: For some reason, this does not seem to cause key repeats like would
    happen if a keyboard key was held down on a text field.

    Args:
      key (str): The key to be pressed down. The valid names are listed in
      pyautogui.KEY_NAMES.

    Returns:
      None
    N   r	   rN   r   rL   r   r   r   )
keyboardMapping	pyautoguiisShiftCharacterdivmodr   windlluser32keybd_eventKEYEVENTF_KEYDOWNKEYEVENTF_KEYUPr;   
needsShiftmodsvkCode	apply_modvk_mods         r"   _keyDownr,     sL    /!!_S%9%A+C00J /#.66LD&#ax.40@		Z&( N N	6 	NM ,,VQ8I1MMM
M$$VQ0A1EEE#ax5:t<tax>N	4 L L	6 	LM ,,VQKKKL Lr!   c                    | t           vst           |          dS t          j        |           }	 t          t           |          d          \  }}|dz  df|dz  df|dz  p|dffD ].\  }}|r't          j        j                            |d	d	d	           /t          j        j                            |d	t          d	           |dz  p|df|dz  df|dz  dffD ]3\  }}|r,t          j        j                            |d	t          d	           4dS )
zPerforms a keyboard key release (without the press down beforehand).

    Args:
      key (str): The key to be released up. The valid names are listed in
      pyautogui.KEY_NAMES.

    Returns:
      None
    Nr  r	   rN   r   rL   r   r   r   )	r  r  r  r   r   r!  r"  r#  r%  r&  s         r"   _keyUpr.  '  sG    /!!_S%9%A+C00J /#.66LD&#ax.40@		Z&( > >	6 	>M ,,VQ1===
M$$VQCCC#ax5:t<tax>N	4 L L	6 	LM ,,VQKKKL Lr!   c                      t           j                                        } t           j        j                            t          j        |                      | j        | j        fS )zReturns the current xy coordinates of the mouse cursor as a two-integer
    tuple by calling the GetCursorPos() win32 function.

    Returns:
      (x, y) tuple of the current xy coordinates of the mouse cursor.
    )	r   r   POINTr!  r"  GetCursorPosbyrefxy)cursors    r"   	_positionr6  O  sI     _""$$F
M%%fl6&:&:;;;Hfhr!   c                      t           j        j                            d          t           j        j                            d          fS )zReturns the width and height of the screen as a two-integer tuple.

    Returns:
      (width, height) tuple of the screen size, in pixels.
    r   r   r   r!  r"  GetSystemMetricsr    r!   r"   _sizer:  \  s6     M 11!44fm6J6[6[\]6^6^__r!   c                 P    t           j        j                            | |           dS )a)  Send the mouse move event to Windows by calling SetCursorPos() win32
    function.

    Args:
      button (str): The mouse button, either 'left', 'middle', or 'right'
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.

    Returns:
      None
    N)r   r!  r"  SetCursorPos)r3  r4  s     r"   _moveTor=  e  s%     M%%a+++++r!   c                    |t           t          t          fvrt          d|z            |t           k    rt          }n%|t          k    rt
          }n|t          k    rt          }	 t          || |           dS # t          t          f$ r Y dS w xY w)a,  Send the mouse down event to Windows by calling the mouse_event() win32
    function.

    Args:
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.
      button (str): The mouse button, either 'left', 'middle', or 'right'

    Returns:
      None
    Jbutton arg to _click() must be one of "left", "middle", or "right", not %sN)
r   r   r   
ValueErrorMOUSEEVENTF_LEFTDOWNMOUSEEVENTF_MIDDLEDOWNMOUSEEVENTF_RIGHTDOWN_sendMouseEventPermissionErrorOSErrorr3  r4  buttonEVs       r"   
_mouseDownrJ  w  s     dFE***ehnnooo~~!	6		#	5"Aq!!!!!W%      "A5 5B
	B
c                    |t           t          t          fvrt          d|z            |t           k    rt          }n%|t          k    rt
          }n|t          k    rt          }	 t          || |           dS # t          t          f$ r Y dS w xY w)a*  Send the mouse up event to Windows by calling the mouse_event() win32
    function.

    Args:
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.
      button (str): The mouse button, either 'left', 'middle', or 'right'

    Returns:
      None
    r?  N)
r   r   r   r@  MOUSEEVENTF_LEFTUPMOUSEEVENTF_MIDDLEUPMOUSEEVENTF_RIGHTUPrD  rE  rF  rG  s       r"   _mouseUprP    s     dFE***ehnnooo~~	6		!	5 Aq!!!!!W%   rK  c                    |t           t          t          fvrt          d|z            |t           k    rt          }n%|t          k    rt
          }n|t          k    rt          }	 t          || |           dS # t          t          f$ r Y dS w xY w)a-  Send the mouse click event to Windows by calling the mouse_event() win32
    function.

    Args:
      button (str): The mouse button, either 'left', 'middle', or 'right'
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.

    Returns:
      None
    r?  N)
r   r   r   r@  MOUSEEVENTF_LEFTCLICKMOUSEEVENTF_MIDDLECLICKMOUSEEVENTF_RIGHTCLICKrD  rE  rF  rG  s       r"   _clickrU    s     dFE***ehnnooo~~"	6		$	%#Aq!!!!!W%   rK  c                  R    t           j        j                            d          dk    S )NrX   r   r8  r    r!   r"   _mouse_is_swappedrW    s"     =004499r!   c                    |dk    r|dk    s
J d            t                      \  }}d|z  |z  dz   }d|z  |z  dz   }t          j        j                            | t          j        |          t          j        |          |d           dS )a  The helper function that actually makes the call to the mouse_event()
    win32 function.

    Args:
      ev (int): The win32 code for the mouse event. Use one of the MOUSEEVENTF_*
      constants for this argument.
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.
      dwData (int): The argument for mouse_event()'s dwData parameter. So far
        this is only used by mouse scrolling.

    Returns:
      None
    Nzx and y cannot be set to Nonei   r   r   )r:  r   r!  r"  mouse_eventc_long)evr3  r4  dwDatawidthheight
convertedX
convertedYs           r"   rD  rD    s     99d$C  GGME6e#a'Jf$q(J
M$$Rz)B)BFMR\D]D]_eghiiiiir!   c                    t                      \  }}t                      \  }}||}n|dk     rd}n||k    r|dz
  }||}n|dk     rd}n||k    r|dz
  }	 t          t          |||            dS # t          t
          f$ r Y dS w xY w)a  Send the mouse vertical scroll event to Windows by calling the
    mouse_event() win32 function.

    Args:
      clicks (int): The amount of scrolling to do. A positive value is the mouse
      wheel moving forward (scrolling up), a negative value is backwards (down).
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.

    Returns:
      None
    Nr   r   )r\  )r6  r:  rD  MOUSEEVENTF_WHEELrE  rF  )clicksr3  r4  startxstartyr]  r^  s          r"   _scrollrf    s     [[NFFGGME6yq55AA%ZZ	Ayq55AA&[[
A)1a??????W%   DDs   A0 0BBc                 $    t          | ||          S )a{  Send the mouse horizontal scroll event to Windows by calling the
    mouse_event() win32 function.

    Args:
      clicks (int): The amount of scrolling to do. A positive value is the mouse
      wheel moving right, a negative value is moving left.
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.

    Returns:
      None
    rf  rc  r3  r4  s      r"   _hscrollrj     s     61a   r!   c                 $    t          | ||          S )af  A wrapper for _scroll(), which does vertical scrolling.

    Args:
      clicks (int): The amount of scrolling to do. A positive value is the mouse
      wheel moving forward (scrolling up), a negative value is backwards (down).
      x (int): The x position of the mouse event.
      y (int): The y position of the mouse event.

    Returns:
      None
    rh  ri  s      r"   _vscrollrl  0  s     61a   r!   )r   )NN):r   ctypes.wintypesr  r   r   r   sysplatform	Exceptionr!  r"  SetProcessDPIAwareAttributeErrorMOUSEEVENTF_MOVErA  rM  rR  rC  rO  rT  rB  rN  rS  MOUSEEVENTF_ABSOLUTErb  MOUSEEVENTF_HWHEELr$  r%  INPUT_MOUSEINPUT_KEYBOARD	Structurer   r$   r)   r.   dict	KEY_NAMESr  updaterangec
VkKeyScanAr   WCHARchrr,  r.  r6  r:  r=  rJ  rP  rU  rW  rD  rf  rj  rl  r    r!   r"   <module>r     s
  
          ) ) ) ) ) ) ) ) ) ) 



<G
)Y
Z
ZZ		=**,,,, 	 	 	D	_    ,/AA   .1DD   03GG           !       !       F$       F   "V $CCy/BCCCDD    zz$z Tz 
4	z
 	$z Tz Tz 	$z dz Tz Dz 
4z Tz z Dz  t!z" d#z z$ T%z& T'z( T)z* T+z, 
4-z. d/z0 t1z2 $3z4 d5z6 $7z8 9z: T;z< D=z> D?z@ dAzB CzD 
4Ez z zF DGzH DIzJ 	$KzL TMzN DOzP dQzR TSzT tUzV TWzX dYzZ [z\ 4]z^ d_z` 
4azb dczd Dezf 
4gz z zh tizj kzl Dmzn Tozp Dqzr Dszt Duzv Dwzx Dyzz D{z| D}z~ Dz@ DAzB DCzD EzF 
4GzH Iz z zJ KzL tMzN dOzP 	$QzR 	$SzT 	$UzV 	$WzX 	$YzZ 	$[z\ 	$]z^ 	$_z` 	$azb 
4czd 
4ezf 
4gzh 
4izj 
4kz z zl 
4mzn 
4ozp 
4qzr 
4szt 
4uzv 
4wzx 
4yzz 
4{z| 
4}z~ 
4z@ tAzB $CzD EzF $GzH IzJ KzL tMz z zN OzP 4QzR dSzT dUzV 4WzX TYzZ [z\ 4]z^ $_z` $azb czd ezf gzh Dizj kzl $mzn oz zp sz z z z z zJ 
r3 ] ]A$m2==fo>S>STWTWXYTZTZ>[>[\\OCCFF*L *L *LZ%L %L %LP
  
  
 ` ` `, , ,$  :  8  :: : :
"j "j "j "jR" " " "J! ! ! ! ! ! ! !s   A AA