o
    &h                     @   sZ   d dl Z d dlZdd Zdd Zdd Zdd	 Zd
d Zdd Zdd ZG dd dZ	dS )    Nc                  C   s$   t t jt jB t j} dd | D S )zHReturns a list of strings of window titles for all visible windows.
    c                 S   s(   g | ]}d |t j |t jdf qS )%s %s )QuartzkCGWindowOwnerNamegetkCGWindowName).0win r
   u/Users/merlin/projects/employee-monitoring-system/venv/lib/python3.10/site-packages/pygetwindow/_pygetwindow_macos.py
<listcomp>   s   ( z getAllTitles.<locals>.<listcomp>)r   CGWindowListCopyWindowInfo#kCGWindowListExcludeDesktopElementskCGWindowListOptionOnScreenOnlykCGNullWindowID)windowsr
   r
   r   getAllTitles   s   r   c                  C   sT   t t jt jB t j} | D ]}|d dkr%d|t j |t jdf   S qtd)z7Returns a Window object of the currently active Window.ZkCGWindowLayerr   r   r   z Could not find an active window.)	r   r   r   r   r   r   r   r   	Exception)r   r	   r
   r
   r   getActiveWindow   s    r   c              
   C   sv   t t jt jB t j}g }|D ])}|d }t| ||d |d |d |d r8|d|t j |	t j
df  q|S )NkCGWindowBoundsXYWidthHeightr   r   )r   r   r   r   r   pygetwindowZpointInRectappendr   r   r   )xyr   matchesr	   wr
   r
   r   getWindowsAt   s   $"r    c                   C      d S Nr
   r
   r
   r
   r   activate$      r#   c                 C   sl   t t jt jB t j}|D ]&}| d|t j |t jdf v r3|d }|d |d |d |d f  S qd S )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )titler   r	   r   r
   r
   r   getWindowGeometry,   s     r'   c                 C   sT   t t jt jB t j}|D ]}| d|t j |t jdf v r'|d dk  S qd S )Nr   r   ZkCGWindowAlphag        r%   )r&   r   r	   r
   r
   r   	isVisible5   s    r(   c                   C   r!   r"   r
   r
   r
   r
   r   isMinimized<   s   r)   c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zedd Zedd Zedd  Zed!d" Zed#d$ Zd%S )&MacOSWindowc                    sX   | _  fdd} fdd} t }tj|j|j|j|j |j|j ||d _d S )Nc                    sB     t}|j j_|j j_|j|j  j_|j	|j  j_
d S r"   )_getWindowRect_hWndleft_rect_lefttop_topright_widthbottom_height)attrNamerselfr
   r   _onReadJ   s
   


z%MacOSWindow.__init__.<locals>._onReadc                    s$     |j|j  |j|j d S r"   )moveTor-   r0   resizeTowidthheight)ZoldBoxZnewBoxr8   r
   r   	_onChangeQ   s   z'MacOSWindow.__init__.<locals>._onChange)ZonChangeZonRead)	r,   r+   ZpyrectZRectr-   r0   r2   r4   r.   )r9   ZhWndr:   r?   r7   r
   r8   r   __init__G   s
   
0zMacOSWindow.__init__c                 C   s@   |  t}|j|j }|j|j }d| jj|j|j||| jf S )Nz=<%s left="%s", top="%s", width="%s", height="%s", title="%s">)	r+   r,   r2   r-   r4   r0   	__class____name__r&   )r9   r7   r=   r>   r
   r
   r   __str__X   s   
zMacOSWindow.__str__c                 C   s   d| j j| jf S )Nz%s(hWnd=%s))rA   rB   r,   r8   r
   r
   r   __repr___   s   zMacOSWindow.__repr__c                 C   s   t |to
| j|jkS r"   )
isinstancer*   r,   )r9   otherr
   r
   r   __eq__c   s   zMacOSWindow.__eq__c                 C      t )zCloses this window. This may trigger "Are you sure you want to
        quit?" dialogs or other actions that prevent the window from
        actually closing. This is identical to clicking the X button on the
        window.NotImplementedErrorr8   r
   r
   r   closeg   r$   zMacOSWindow.closec                 C   rH   )zMinimizes this window.rI   r8   r
   r
   r   minimizen      zMacOSWindow.minimizec                 C   rH   )zMaximizes this window.rI   r8   r
   r
   r   maximizes   rM   zMacOSWindow.maximizec                 C   rH   )zCIf maximized or minimized, restores the window to it's normal size.rI   r8   r
   r
   r   restorex   rM   zMacOSWindow.restorec                 C   rH   )z7Activate this window and make it the foreground window.rI   r8   r
   r
   r   r#   }   rM   zMacOSWindow.activatec                 C   rH   )z0Resizes the window relative to its current size.rI   )r9   ZwidthOffsetZheightOffsetr
   r
   r   	resizeRel   rM   zMacOSWindow.resizeRelc                 C   rH   )z-Resizes the window to a new width and height.rI   )r9   ZnewWidthZ	newHeightr
   r
   r   r<      rM   zMacOSWindow.resizeToc                 C   rH   )z2Moves the window relative to its current position.rI   )r9   ZxOffsetZyOffsetr
   r
   r   moveRel   rM   zMacOSWindow.moveRelc                 C   rH   )z2Moves the window to new coordinates on the screen.rI   )r9   ZnewLeftZnewTopr
   r
   r   r;      rM   zMacOSWindow.moveToc                 C   rH   )z2Returns True if the window is currently minimized.rI   r8   r
   r
   r   r)         zMacOSWindow.isMinimizedc                 C   rH   )z2Returns True if the window is currently maximized.rI   r8   r
   r
   r   isMaximized   rR   zMacOSWindow.isMaximizedc                 C   rH   )zFReturns True if the window is currently the active, foreground window.rI   r8   r
   r
   r   isActive   rR   zMacOSWindow.isActivec                 C   rH   )z%Returns the window title as a string.rI   r8   r
   r
   r   r&      rR   zMacOSWindow.titlec                 C   rH   r"   rI   r8   r
   r
   r   visible   rM   zMacOSWindow.visibleN)rB   
__module____qualname__r@   rC   rD   rG   rK   rL   rN   rO   r#   rP   r<   rQ   r;   propertyr)   rS   rT   r&   rU   r
   r
   r
   r   r*   F   s0    



r*   )
r   r   r   r   r    r#   r'   r(   r)   r*   r
   r
   r
   r   <module>   s    		
