o
    'hQ                     @   s  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ze j	j
  W n	 ey4   Y nw 	 dZdZdZee ZdZd	Zee Zd
ZdZee ZdZdZdZd ZdZd ZdZG dd de jZG dd de jZ G dd de jZ!G dd de jZ"	 e#d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/d0d1d0d2d0i d3d4d5d6d7d8d9d8d:d;d<d;d=d>d?d@dAdBdCdDdEd
dFd
dGdHdIdJdKdHdLdJdMdNi dOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dad`dbd`dcd`dddedfdgdhdgdidjdkdi dlddmdndodpdqdrdsdtdudvdwdxdydzd{d|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 ]Z(e j	j
)e j*+e,e(e%e,e(< qdd Z-dd Z.dd Z/dd Z0dd Z1d d Z2dd Z3dd Z4dd Z5ddd	Z6dd
dZ7dd Z8dd Z9dS (      N)LEFTMIDDLERIGHTwin32zCThe pyautogui_win module should only be loaded on a Windows system.                   @   i   i   i   c                	   @   sR   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ejjfgZ	dS )
MOUSEINPUTZdxZdyZ	mouseDatadwFlagstimedwExtraInfoN)
__name__
__module____qualname__ctypeswintypesLONGDWORDPOINTERULONG_fields_ r   r   o/Users/merlin/projects/employee-monitoring-system/venv/lib/python3.10/site-packages/pyautogui/_pyautogui_win.pyr   >   s    




r   c                   @   sH   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ejjfgZ	dS )
KEYBDINPUTZwVkZwScanr   r   r   N)
r   r   r   r   r   WORDr   r   r   r   r   r   r   r   r   H   s    



r   c                   @   s.   e Zd ZdejjfdejjfdejjfgZdS )HARDWAREINPUTZuMsgZwParamLZwParamHN)r   r   r   r   r   r   r   r   r   r   r   r   r   Q   s
    


r   c                   @   s6   e Zd ZG dd dejZdZdejjfdefgZ	dS )INPUTc                   @   s"   e Zd ZdefdefdefgZdS )zINPUT._ImiZkihiN)r   r   r   r   r   r   r   r   r   r   r   _IY   s
    r#   )ityper$   N)
r   r   r   r   Unionr#   Z_anonymous_r   r   r   r   r   r   r   r    X   s    
r    c                 C   s   g | ]}|d fqS )Nr   ).0keyr   r   r   
<listcomp>p   s    r)   Z	backspacesuper[   tab	   	clear   Zenter   
returnshiftZctrl   Zalt   pause   Zcapslock   Zkana   ZhanguelZhangulZjunja   final   Zhanja   Zkanjiesc   escapeconvert   Z
nonconvert   accept   Z
modechange    spaceZpgup!   Zpgdn"   ZpageupZpagedownend#   home$   left%   up&   right'   Zdown(   select)   print*   execute+   Zprtsc,   ZprtscrZprntscrnZprintscreeninsert-   del.   deletehelp/   winZwinleftZwinright\   Zapps]   sleep_   Znum0`   Znum1a   Znum2b   Znum3c   Znum4d   Znum5e   Znum6f   Znum7g   Znum8h   Znum9i   multiplyj   addk   	separatorl   subtractm   decimaln   divideo   f1p   f2q   Zf3r   Zf4s   Zf5t   Zf6u   Zf7v   Zf8w   Zf9x   Zf10y   Zf11z   Zf12{   Zf13|   Zf14}   Zf15~   Zf16   Zf17   Zf18   Zf19   Zf20   Zf21   Zf22   Zf23   Zf24   Znumlock   Z
scrolllock   Z	shiftleft   Z
shiftright   Zctrlleft   Z	ctrlright   Zaltleft   Zaltright   Zbrowserback   Zbrowserforward   Zbrowserrefresh   Zbrowserstop   Zbrowsersearch   Zbrowserfavorites   Zbrowserhome   Z
volumemute   Z
volumedown   Zvolumeup   Z	nexttrack   Z	prevtrack   stop   Z	playpause   Z
launchmail   Zlaunchmediaselect         )Z
launchapp1Z
launchapp2c                 C   s   | t vs
t |  du rdS t| }	 tt |  d\}}|d@ df|d@ df|d@ p*|dffD ]\}}|r>tjj|d	td	 q.tjj|d	td	 |d@ pN|df|d@ df|d@ dffD ]\}}|rltjj|d	t	d	 q\d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   r7   r   r6   r   r
   r   )
keyboardMapping	pyautoguiisShiftCharacterdivmodr   windlluser32keybd_eventKEYEVENTF_KEYDOWNKEYEVENTF_KEYUPr(   Z
needsShiftmodsZvkCodeZ	apply_modZvk_modr   r   r   _keyDown   s&   

r   c                 C   s   | t vs
t |  du rdS t| }	 tt |  d\}}|d@ df|d@ df|d@ p*|dffD ]\}}|r>tjj|d	d	d	 q.tjj|d	td	 |d@ pN|df|d@ df|d@ dffD ]\}}|rltjj|d	td	 q\d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   r7   r   r6   r   r
   r   )	r   r   r   r   r   r   r   r   r   r   r   r   r   _keyUp'  s&   


r   c                  C   s*   t j } t jjt |  | 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   ZPOINTr   r   ZGetCursorPosZbyrefxy)cursorr   r   r   	_positionO  s   
r   c                   C   s   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   ZGetSystemMetricsr   r   r   r   _size\  s   r   c                 C   s   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   ZSetCursorPos)r   r   r   r   r   _moveToe  s   r   c              	   C   n   |t ttfvrtd| |t krt}n|tkrt}n|tkr!t}z	t|| | W dS  tt	fy6   Y dS 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r   r   ZbuttonZEVr   r   r   
_mouseDownw     r   c              	   C   r   )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_RIGHTUPr   r   r   r   r   r   r   _mouseUp  s   r   c              	   C   r   )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_RIGHTCLICKr   r   r   r   r   r   r   _click  r   r   c                   C   s   t jjddkS )Nr<   r   r   r   r   r   r   _mouse_is_swapped  s   r   c                 C   sh   |dkr|dksJ dt  \}}d| | d }d| | d }tjj| t|t||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   Zmouse_eventZc_long)Zevr   r   dwDatawidthheightZ
convertedXZ
convertedYr   r   r   r     s
   
&r   c              	   C   s   t  \}}t \}}|du r|}n|dk rd}n||kr |d }|du r'|}n|dk r.d}n||kr6|d }ztt||| d W dS  ttfyM   Y dS 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   )r   r   r   MOUSEEVENTF_WHEELr   r   )clicksr   r   ZstartxZstartyr   r   r   r   r   _scroll  s&   

r   c                 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
    r   r   r   r   r   r   r   _hscroll   s   r   c                 C   r   )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
    r   r   r   r   r   _vscroll0  s   r   )r   )NN):r   Zctypes.wintypesr   r   r   r   sysplatform	Exceptionr   r   ZSetProcessDPIAwareAttributeErrorZMOUSEEVENTF_MOVEr   r   r   r   r   r   r   r   r   ZMOUSEEVENTF_ABSOLUTEr   ZMOUSEEVENTF_HWHEELr   r   ZINPUT_MOUSEZINPUT_KEYBOARDZ	Structurer   r   r   r    dictZ	KEY_NAMESr   updaterangecZ
VkKeyScanAr   ZWCHARchrr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   sL  

		
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx
 &-(	)%