web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Take a screenshot of a...
Power Automate
Unanswered

Take a screenshot of a Web page - for multiple elements

(0) ShareShare
ReportReport
Posted on by 7

Hi,

 

I'm using an action in PAD called "Take a screenshot of a Web page" with "Specific element" as an option.  This works fine as expected.

However, wondering if I want to extend this functionality to take a snap of multiple elements and not just one, something like customized screenshot of two elements (say for two div elements with different ids) or a partial page.  Is there a way to do this?

Jameelrrf_0-1719396196143.png

 

Thanks in advance.

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @Jameelrrf 

     

    You cannot accomplish this directly, but once you take screenshots of multiple elements as separate images, you may use a scripting language like C# or any other language to merge them.

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • Jameelrrf Profile Picture
    7 on at

    @Deenuji , Thanks for your response.  Would you point me to any article or the steps to merge the images with any scripting language within PAD.  

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @Jameelrrf 

     

    Interesting ask:) I have explored this option as part of your request so thanks 🙂

     

    Please follow the below approach:

    Deenuji_0-1719403180665.png

     

    PAD flow code:

    SET inputImage1 TO $'''C:\\Boot\\1.png'''
    SET inputImage2 TO $'''C:\\Boot\\2.png'''
    SET outputImage TO $'''C:\\Boot\\MergedImage.jpg'''
    @@copilotGeneratedAction: 'True'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''# Function to check if an assembly is loaded
    function Is-AssemblyLoaded {
     param (
     [string]$assemblyName
     )
     
     $loadedAssemblies = [AppDomain]::CurrentDomain.GetAssemblies() | ForEach-Object { $_.GetName().Name }
     return $loadedAssemblies -contains $assemblyName
    }
    
    # Check if System.Drawing is loaded, if not, load it
    if (-not (Is-AssemblyLoaded -assemblyName \"System.Drawing\")) {
     try {
     Add-Type -AssemblyName System.Drawing
     Write-Output \"System.Drawing assembly loaded successfully.\"
     } catch {
     Write-Error \"Failed to load System.Drawing assembly: $_\"
     exit
     }
    } else {
     Write-Output \"System.Drawing assembly is already loaded.\"
    }
    
    
    # Define paths to the images
    $image1Path = \"%inputImage1%\"
    $image2Path = \"%inputImage2%\"
    $outputPath = \"%outputImage%\"
    
    
    try {
     # Load the images
     Write-Output \"Loading Image 1 from $image1Path\"
     $image1 = [System.Drawing.Image]::FromFile($image1Path)
    
     Write-Output \"Loading Image 2 from $image2Path\"
     $image2 = [System.Drawing.Image]::FromFile($image2Path)
    
     # Determine the dimensions of the merged image
     $width = [Math]::Max($image1.Width, $image2.Width)
     $height = $image1.Height + $image2.Height
    
     # Create a new bitmap to hold the merged image
     Write-Output \"Creating a new bitmap with dimensions $width x $height\"
     $mergedImage = New-Object System.Drawing.Bitmap($width, $height)
    
     # Create a graphics object to draw the images onto the bitmap
     $graphics = [System.Drawing.Graphics]::FromImage($mergedImage)
    
     # Draw the first image
     Write-Output \"Drawing Image 1\"
     $graphics.DrawImage($image1, 0, 0, $image1.Width, $image1.Height)
    
     # Draw the second image below the first image
     Write-Output \"Drawing Image 2\"
     $graphics.DrawImage($image2, 0, $image1.Height, $image2.Width, $image2.Height)
    
     # Save the merged image
     Write-Output \"Saving the merged image to $outputPath\"
     $mergedImage.Save($outputPath, [System.Drawing.Imaging.ImageFormat]::Jpeg)
    
     # Clean up
     $image1.Dispose()
     $image2.Dispose()
     $mergedImage.Dispose()
     $graphics.Dispose()
    
     Write-Output \"Merged image saved to $outputPath\"
    } catch {
     Write-Error \"An error occurred: $_\"
    }''' ScriptOutput=> PowershellOutput

     

     

    How to copy/paste the above code into PAD?

    Deenuji_1-1719403267318.gif

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 355

#2
11manish Profile Picture

11manish 336 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard