+
    Siq"                    6  a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIHtHtHtH	t	H
t
 ^ RIHtHtHtHtHtHtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHtHt ^ RIH t  ^ RI!H"t" ]'       d   ^ R	I#H$t$H%t% ^ R
I&H't' R#t(Rt)^ t*Rt+ ! R R]4      t, ! R R]4      t-]! ]]]]! ]4      ]4      t.RR]]]]]]]]].	]3RR]]].]3RR].]3RR].]3RR].]3RR]]
].].]3RR]].]3RR]]]]]
]! ]-4      ].]3RR].]3RR].]3RR]].]	3RR]].]3/t/R ]0R!&    ! R" R] 4      t1R# )$zXThis is part of the MSS Python's module.
Source: https://github.com/BoboTiG/python-mss.
)annotationsN)POINTERWINFUNCTYPE	Structurec_intc_void_p)BOOLDOUBLEDWORDHBITMAPHDCHGDIOBJHWNDINTLONGLPARAMLPRECTRECTUINTWORD)local)TYPE_CHECKINGAny)MSSBase)ScreenShotError)
CFunctionsMonitor)
ScreenShotMSSi   @i   c                  `    ] tR t^,tRtR]3R]3R]3R]3R]3R]3R]3R	]3R
]3R]3R]33tRt	R# )BITMAPINFOHEADERz;Information about the dimensions and color format of a DIB.biSizebiWidthbiHeightbiPlanes
biBitCountbiCompressionbiSizeImagebiXPelsPerMeterbiYPelsPerMeter	biClrUsedbiClrImportant N)
__name__
__module____qualname____firstlineno____doc__r
   r   r   _fields___static_attributes__r,       Q/Users/mibo/.openclaw/workspace/.venv/lib/python3.14/site-packages/mss/windows.pyr    r    ,   sf    E 
5	D	T	T	t	% 		D!	D!	e	5!Hr4   r    c                  8    ] tR t^>tRtR]3R]^,          33tRtR# )
BITMAPINFOzFStructure that defines the dimensions and color information for a DIB.	bmiHeader	bmiColorsr,   N)	r-   r.   r/   r0   r1   r    r
   r2   r3   r,   r4   r5   r7   r7   >   s    P./+uqy1IJHr4   r7   BitBltgdi32CreateCompatibleBitmapCreateCompatibleDCDeleteDCDeleteObjectEnumDisplayMonitorsuser32GetDeviceCaps	GetDIBitsGetSystemMetricsGetWindowDC	ReleaseDCSelectObjectr   
CFUNCTIONSc                     a  ] tR t^]tRt0 RmtR V 3R lltR R ltR R ltR R	 lt	R
 R lt
R R ltR R ltRtV ;t# )r   z:Multiple ScreenShots implementation for Microsoft Windows.c                    V ^8  d   QhRRRR/# )   kwargsr   returnNoner,   )formats   "r5   __annotate__MSS.__annotate__b   s        C  D  r4   c               6  < \         SV `  ! R/ VB  \        P                  ! R4      V n        \        P                  ! R4      V n        V P                  4        V P                  4        \        4       V n	        RV P                  n
        RV P                  n        V P                  P                  ^ 4      V P                  n        V P
                  P                  V P                  P                  4      V P                  n        \!        4       p\        P"                  ! \$        4      VP&                  n        ^VP&                  n        ^ VP&                  n        ^ VP&                  n        ^ VP&                  n        ^ VP&                  n        W P                  n        R# )zWindows initialisations.rA   r;   Nr,   )    rS   )super__init__ctypesWinDLLrA   r;   _set_cfunctions_set_dpi_awarenessr   _handlesregion_width_heightbmprE   srcdcr=   memdcr7   sizeofr    r8   r!   r$   r%   r&   r*   r+   bmi)selfrL   r`   	__class__s   ", r5   rU   MSS.__init__b   s   "6"mmH-]]7+
! ,2) "kk55a8"jj;;DMM<O<OPl%}}-=>!"#% &'#"#'($r4   c                   V ^8  d   QhRR/# rK   rM   rN   r,   )rO   s   "r5   rP   rQ   {   s     ' 't 'r4   c                	4   V P                   P                  '       dA   V P                  P                  V P                   P                  4       R V P                   n        V P                   P                  '       dA   V P                  P                  V P                   P                  4       R V P                   n        V P                   P                  '       dD   V P                  P                  ^ V P                   P                  4       R V P                   n        R # R # )N)	rZ   r\   r;   r?   r^   r>   r]   rA   rF   ra   s   &r5   close	MSS.close{   s    ==JJ##DMM$5$56 $DMM==JJ 3 34"&DMM==KK!!!T]]%8%89"&DMM r4   c                   V ^8  d   QhRR/# re   r,   )rO   s   "r5   rP   rQ      s     ; ; ;r4   c                    V P                   pRV P                  RV P                  /p\        P	                  4        F  w  pw  rEpV! W$,          W5V4       K  	  R# )z7Set all ctypes functions and attach them to attributes.r;   rA   N)	_cfactoryr;   rA   rH   items)ra   cfactoryattrsfuncattrargtypesrestypes   &      r5   rX   MSS._set_cfunctions   sR    >>TZZdkk
 0:/?/?/A+D+47U[$': 0Br4   c                   V ^8  d   QhRR/# re   r,   )rO   s   "r5   rP   rQ      s     - -D -r4   c                    \         P                  ! 4       R,          pVR8  d,   \        P                  P                  P                  ^4       R# RTu;8:  d   R8  d!   M R# V P                  P                  4        R# R# )z<Set DPI awareness to capture full screen on Hi-DPI monitors.:NrK   NN)      )rw   rS   )sysgetwindowsversionrV   windllshcoreSetProcessDpiAwarenessrA   SetProcessDPIAware)ra   versions   & r5   rY   MSS._set_dpi_awareness   s\    '')"-f MM  77:w'''KK**, (r4   c                   V ^8  d   QhRR/# re   r,   )rO   s   "r5   rP   rQ      s     !6 !6 !6r4   c                >  a a \         oS P                  pVP                  pS P                  P	                  RS! V! ^L4      4      RS! V! ^M4      4      RS! V! ^N4      4      RS! V! ^O4      4      /4       R VV 3R llp\        V4      pVP                  ^ ^ V^ 4       R# )z;Get positions of monitors. It will populate self._monitors.lefttopwidthheightc          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
rK   _monitorint_datar   rectr   _dcr   rM   r,   )rO   s   "r5   rP   (MSS._monitors_impl.<locals>.__annotate__   s/     	 	 	C 	v 	F 	s 	r4   c                B  < VP                   pSP                  P                  RS! VP                  4      RS! VP                  4      RS! VP
                  4      S! VP                  4      ,
          RS! VP                  4      S! VP                  4      ,
          /4       ^# )zXCallback for monitorenumproc() function, it will return
a RECT with appropriate values.
r   r   r   r   )contents	_monitorsappendr   r   rightbottom)r   r   r   r   rctint_ra   s   &&&& r5   	_callback%MSS._monitors_impl.<locals>._callback   sy     --CNN!!DN4=T#))_tCHH~=d3::.cgg>	 r4   N)r   rA   rD   r   r   MONITORNUMPROCr@   )ra   rA   get_system_metricsr   callbackr   s   f    @r5   _monitors_implMSS._monitors_impl   s    #44 	/34t.r23045$1"56		
	 	 "),""1a15r4   c                    V ^8  d   QhRRRR/# )rK   monitorr   rM   r   r,   )rO   s   "r5   rP   rQ      s     2F 2F' 2F 2Fr4   c                  V P                   P                  V P                   P                  r2V P                  pVR,          VR,          reV P                   P                  WV38w  Ed   WV3V P                   n        WPP                   P
                  P                  n        V) V P                   P
                  P                  n        \        P                  ! WV,          ^,          4      V P                   n        V P                   P                  '       d&   VP                  V P                   P                  4       VP                  W%V4      V P                   n        VP                  W0P                   P                  4       VP!                  V^ ^ WVW!R,          VR,          \"        \$        ,          4	       VP'                  W0P                   P                  ^ W`P                   P                  V P                   P
                  \(        4      pWv8w  d   Rp\+        V4      hV P-                  \/        V P                   P                  4      V4      # )a  Retrieve all pixels from a monitor. Pixels have to be RGB.

In the code, there are a few interesting things:

[1] bmi.bmiHeader.biHeight = -height

A bottom-up DIB is specified by setting the height to a
positive number, while a top-down DIB is specified by
setting the height to a negative number.
https://msdn.microsoft.com/en-us/library/ms787796.aspx
https://msdn.microsoft.com/en-us/library/dd144879%28v=vs.85%29.aspx


[2] bmi.bmiHeader.biBitCount = 32
    image_data = create_string_buffer(height * width * 4)

We grab the image in RGBX mode, so that each word is 32bit
and we have no striding.
Inspired by https://github.com/zoofIO/flexx


[3] bmi.bmiHeader.biClrUsed = 0
    bmi.bmiHeader.biClrImportant = 0

When biClrUsed and biClrImportant are set to zero, there
is "no" color table, so we can read the pixels of the bitmap
retrieved by gdi32.GetDIBits() as a sequence of RGB values.
Thanks to http://stackoverflow.com/a/3688682
r   r   r   r   zgdi32.GetDIBits() failed.)rZ   r]   r^   r;   r[   r`   r8   r"   r#   rV   create_string_bufferdatar\   r?   r<   rG   r:   SRCCOPY
CAPTUREBLTrC   DIB_RGB_COLORSr   	cls_image	bytearray)	ra   r   r]   r^   gdir   r   bitsmsgs	   ""       r5   
_grab_implMSS._grab_impl   s   < }}**DMM,?,?ujj('(*;v==,,?16DMM-27MM''/4:7DMM''0!'!<!<U^a=O!PDMM}}     !2!23 # : :5 PDMMUMM$5$56

5!Qufowu~W^akWkl}}UMM$5$5q&--BTBTVZVcVcVgVgiwx>-C!#&&~~i(:(:;WEEr4   c                   V ^8  d   QhRR/# )rK   rM   zScreenShot | Noner,   )rO   s   "r5   rP   rQ      s      / r4   c                    R# )z0Retrieve all cursor data. Pixels have to be RGB.Nr,   rg   s   &r5   _cursor_implMSS._cursor_impl   s    r4   )rZ   r;   rA   >   r;   rA   rZ   )r-   r.   r/   r0   r1   	__slots__rU   rh   rX   rY   r   r   r   r3   __classcell__)rb   s   @r5   r   r   ]   s;    D/I   2';-!6F2Fh r4   )r   )2__conditional_annotations__r1   
__future__r   rV   ry   r   r   r   r   r   ctypes.wintypesr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   	threadingr   typingr   r   mss.baser   mss.exceptionr   
mss.modelsr   r   mss.screenshotr   __all__r   r   r   r    r7   r   rH   __annotations__r   )r   s   @r5   <module>r      s   #  
 C C      %  ).)
 

y $K K S%vF wc3S#sCGNwc3A7SE3/3%%Wwi-HsHnf&MtTgc{C0'C$h
@SUYZ\`aC5#.Htfc*(T3K/WsGng6
J "]' ]r4   