simple-rdp 0.8.3__cp314-cp314-win_amd64.whl → 0.8.5__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
simple_rdp/client.py CHANGED
@@ -409,7 +409,7 @@ class RDPClient:
409
409
  """
410
410
  return await self._display.screenshot()
411
411
 
412
- async def pointer_area_screenshot(self) -> tuple[Image.Image, tuple[int, int]]:
412
+ async def pointer_area_screenshot(self) -> tuple[Image.Image, tuple[int, int], tuple[int, int]]:
413
413
  """
414
414
  Capture a cropped area around the pointer position.
415
415
 
@@ -418,12 +418,26 @@ class RDPClient:
418
418
  near edges, the crop is clamped to stay within display bounds.
419
419
 
420
420
  Returns:
421
- Tuple of (cropped_image, (top_x, top_y)) where:
421
+ Tuple of (cropped_image, (top_x, top_y), (bottom_x, bottom_y)) where:
422
422
  - cropped_image: Cropped region with pointer composited
423
423
  - (top_x, top_y): Top-left corner position of crop relative to display
424
+ - (bottom_x, bottom_y): Bottom-right corner position of crop relative to display
424
425
  """
425
426
  return await self._display.pointer_area_screenshot()
426
427
 
428
+ async def screenshot_with_crop(self, top_left: tuple[int, int], bottom_right: tuple[int, int]) -> Image.Image:
429
+ """
430
+ Capture a cropped area of the screen.
431
+
432
+ Args:
433
+ top_left: (x, y) coordinates of the top-left corner of the crop area.
434
+ bottom_right: (x, y) coordinates of the bottom-right corner of the crop area.
435
+
436
+ Returns:
437
+ Cropped PIL Image of the specified region with pointer composited.
438
+ """
439
+ return await self._display.screenshot_with_crop(top_left, bottom_right)
440
+
427
441
  async def save_screenshot(self, path: str) -> None:
428
442
  """
429
443
  Save a screenshot to a file.
simple_rdp/display.py CHANGED
@@ -528,7 +528,43 @@ class Display:
528
528
  img.save(path)
529
529
  logger.info(f"Screenshot saved to {path}")
530
530
 
531
- async def pointer_area_screenshot(self) -> tuple[Image.Image, tuple[int, int]]:
531
+ async def screenshot_with_crop(self, top_left: tuple[int, int], bottom_right: tuple[int, int]) -> Image.Image:
532
+ """
533
+ Capture a cropped area of the screen.
534
+
535
+ Args:
536
+ top_left: (x, y) coordinates of the top-left corner of the crop area.
537
+ bottom_right: (x, y) coordinates of the bottom-right corner of the crop area.
538
+
539
+ Returns:
540
+ Cropped PIL Image of the specified region with pointer composited.
541
+ """
542
+ async with self._screen_lock:
543
+ if self._raw_display_image is None:
544
+ crop_w = bottom_right[0] - top_left[0]
545
+ crop_h = bottom_right[1] - top_left[1]
546
+ return Image.new("RGB", (max(1, crop_w), max(1, crop_h)), (0, 0, 0))
547
+
548
+ # Update final display image if dirty
549
+ if self._final_display_image_dirty or self._final_display_image is None:
550
+ self._update_final_display_image()
551
+
552
+ assert self._final_display_image is not None
553
+
554
+ # Clamp coordinates to display bounds
555
+ x1 = max(0, min(top_left[0], self._width))
556
+ y1 = max(0, min(top_left[1], self._height))
557
+ x2 = max(0, min(bottom_right[0], self._width))
558
+ y2 = max(0, min(bottom_right[1], self._height))
559
+
560
+ # Ensure valid crop dimensions
561
+ if x2 <= x1 or y2 <= y1:
562
+ return Image.new("RGB", (1, 1), (0, 0, 0))
563
+
564
+ cropped = self._final_display_image.crop((x1, y1, x2, y2))
565
+ return cropped.copy()
566
+
567
+ async def pointer_area_screenshot(self) -> tuple[Image.Image, tuple[int, int], tuple[int, int]]:
532
568
  """
533
569
  Capture a cropped area around the pointer position.
534
570
 
@@ -537,15 +573,16 @@ class Display:
537
573
  near edges, the crop is clamped to stay within display bounds.
538
574
 
539
575
  Returns:
540
- Tuple of (cropped_image, (top_x, top_y)) where:
576
+ Tuple of (cropped_image, (top_x, top_y), (bottom_x, bottom_y)) where:
541
577
  - cropped_image: Cropped region with pointer composited
542
578
  - (top_x, top_y): Top-left corner position of crop relative to display
579
+ - (bottom_x, bottom_y): Bottom-right corner position of crop relative to display
543
580
  """
544
581
  async with self._screen_lock:
545
582
  if self._raw_display_image is None:
546
583
  crop_w = self._width // 3
547
584
  crop_h = self._height // 3
548
- return (Image.new("RGB", (crop_w, crop_h), (0, 0, 0)), (0, 0))
585
+ return (Image.new("RGB", (crop_w, crop_h), (0, 0, 0)), (0, 0), (crop_w, crop_h))
549
586
 
550
587
  # Update final display image if dirty
551
588
  if self._final_display_image_dirty or self._final_display_image is None:
@@ -565,10 +602,14 @@ class Display:
565
602
  top_x = max(0, min(top_x, self._width - crop_w))
566
603
  top_y = max(0, min(top_y, self._height - crop_h))
567
604
 
605
+ # Calculate bottom-right corner
606
+ bottom_x = top_x + crop_w
607
+ bottom_y = top_y + crop_h
608
+
568
609
  # Crop the image
569
- cropped = self._final_display_image.crop((top_x, top_y, top_x + crop_w, top_y + crop_h))
610
+ cropped = self._final_display_image.crop((top_x, top_y, bottom_x, bottom_y))
570
611
 
571
- return (cropped.copy(), (top_x, top_y))
612
+ return (cropped.copy(), (top_x, top_y), (bottom_x, bottom_y))
572
613
 
573
614
  async def apply_bitmap(
574
615
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simple-rdp
3
- Version: 0.8.3
3
+ Version: 0.8.5
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -0,0 +1,14 @@
1
+ simple_rdp\__init__.py,sha256=zJw8lC4mIERiJQJb1ziRaS5pUNGNcE1z8xuGymxwwB8,717
2
+ simple_rdp\_rle.cp314-win_amd64.pyd,sha256=hHMHZcWqYCFXQox5pkXUohDq7hvtym81Wx55iGc_uh8,195072
3
+ simple_rdp\capabilities.py,sha256=jAP3SYjPORIDLV0p2tKD21jq3ulthd6NgpYVJ2uv1vg,17797
4
+ simple_rdp\client.py,sha256=6J6actlIuYrxO-qyD8gMg5SU_77k4V4ibFQStp2RXcw,73122
5
+ simple_rdp\credssp.py,sha256=nf75WpBvL8X7i4nT5o27tmfPCwkLhAfamBzMlXnd5CE,16370
6
+ simple_rdp\display.py,sha256=uMIrQeUfjvy6VfBNpE9p5X0g8HRkHsJQBGZn9sYemmQ,41609
7
+ simple_rdp\input.py,sha256=nnSEac9t4j72ZdCvhhDMcXGu9KwoqRCdzpyZxnUg_AE,938
8
+ simple_rdp\mcs.py,sha256=egSTKViZVXd0uaUBPorc9ia79xa0XwUgnTm3u5G2eXw,26462
9
+ simple_rdp\pdu.py,sha256=GRat4fJ56zhSvy0QtP5tBqpClDNTCH6CPp9FELrXTxw,18713
10
+ simple_rdp-0.8.5.dist-info\METADATA,sha256=SvSlgmpGhU6-cRSVKjCHYPMS_Sn85KKn7cO3bwsDKjE,11619
11
+ simple_rdp-0.8.5.dist-info\WHEEL,sha256=TASrtxyeL-Pi7odwPBMCgR1YebCHdBFZvgqiADG_4b0,97
12
+ simple_rdp-0.8.5.dist-info\entry_points.txt,sha256=CPwBu2L4Vh3MZwYYlTAotNUElilT43OKdi3UnHTTKQ4,66
13
+ simple_rdp-0.8.5.dist-info\licenses\LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
14
+ simple_rdp-0.8.5.dist-info\RECORD,,
@@ -1,14 +0,0 @@
1
- simple_rdp\__init__.py,sha256=zJw8lC4mIERiJQJb1ziRaS5pUNGNcE1z8xuGymxwwB8,717
2
- simple_rdp\_rle.cp314-win_amd64.pyd,sha256=lH0x7U3KgPc4o64v6AR-zQr1c7_zZ9wEcOzDFKOMl30,195072
3
- simple_rdp\capabilities.py,sha256=jAP3SYjPORIDLV0p2tKD21jq3ulthd6NgpYVJ2uv1vg,17797
4
- simple_rdp\client.py,sha256=4mhXFbcMMls-jSKdkXg_zniNFxsoQBD1xL5MBHLAybU,72426
5
- simple_rdp\credssp.py,sha256=nf75WpBvL8X7i4nT5o27tmfPCwkLhAfamBzMlXnd5CE,16370
6
- simple_rdp\display.py,sha256=cf31w5xPWh--vl3p6rnM3vNJrXr_ATx7gcE9JCOnQQ8,39764
7
- simple_rdp\input.py,sha256=nnSEac9t4j72ZdCvhhDMcXGu9KwoqRCdzpyZxnUg_AE,938
8
- simple_rdp\mcs.py,sha256=egSTKViZVXd0uaUBPorc9ia79xa0XwUgnTm3u5G2eXw,26462
9
- simple_rdp\pdu.py,sha256=GRat4fJ56zhSvy0QtP5tBqpClDNTCH6CPp9FELrXTxw,18713
10
- simple_rdp-0.8.3.dist-info\METADATA,sha256=N6LDHByeGL4X9V67HAsUE_eBLyvDDCLHuXep3_RTYrs,11619
11
- simple_rdp-0.8.3.dist-info\WHEEL,sha256=TASrtxyeL-Pi7odwPBMCgR1YebCHdBFZvgqiADG_4b0,97
12
- simple_rdp-0.8.3.dist-info\entry_points.txt,sha256=CPwBu2L4Vh3MZwYYlTAotNUElilT43OKdi3UnHTTKQ4,66
13
- simple_rdp-0.8.3.dist-info\licenses\LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
14
- simple_rdp-0.8.3.dist-info\RECORD,,