Reputation: 1
I am trying to take screenshots of a pane in a windows app without any overlap between scrolls using Python.
This is the code I have so far. When I run this, it works but there is overlap on the stitched screenshot. There are no bugs that in the code that I can tell. I have tried adjusting the height (new_image.paste(image2, (0, 273))) in an attempt to stitch correctly, but have has no luck. Also, in my research on the topic, I have not found a way to stitch the screenshots correctly. This is a bot build so I would like it to calculate the dimensions so that the user does not have to edit the dimensions manually.
def autosetup_summary_scroll():
windows = Windows()
autosetup= window.find_window(f'name: "AutoSetup - PathGroup - {location} - {environment} {version} - {admin} - {search_type}"')
window_title = f"AutoSetup - PathGroup - {location} - {environment} {version} - {admin} - {search_type}"
autosetup = window.find_window(f'name: "{window_title}"')
app = autosetup.find_child_window('id: "1129"')
app.click()
app.screenshot(filename="screenshot_before_scroll.png")
# app.ui_automation_control.GetLegacyIAccessiblePattern
desktop.press_keys('page_down')
#summaryscroll.update.geometry()
app.screenshot(filename="screenshot_after_scroll.png")
stitch_screenshots_vertically('screenshot_before_scroll.png', 'screenshot_after_scroll.png', 'stitched_screenshot.png')
def stitch_screenshots_vertically(screenshot_before_scroll, screenshot_after_scroll, stitched_screenshot):
# Load the images
image1 = Image.open(screenshot_before_scroll)
image2 = Image.open(screenshot_after_scroll)
# Calculate the total height and the maximum width
total_height = image1.height + image2.height
max_width = max(image1.width, image2.width)
# Create a new blank image with the calculated size
new_image = Image.new('RGB', (max_width, total_height))
#update.geomerty
# Paste the images into the new image, one above the other
new_image.paste(image1, (0, 0))
new_image.paste(image2, (0, 273))
#update.geometry
# Save the combined image to the specified path
new_image.save(fp="stitched_screenshot.png")
Upvotes: 0
Views: 102