29-11-23 06:06 AM
29-11-23 10:48 PM
I worked on the code to capture screenshots, made some tweaks, and gave it a test spin and it worked from my end. It looks good now.
Dim startPoint As New Point(StartX, StartY)
Dim endPoint As New Point(EndX, EndY)
Dim ScreenshotImage As Bitmap
Dim FullSavedScreenshotPath As String
If startPoint = endPoint Then
Exit Sub
End If
Dim size As New Size(Math.Abs(endPoint.X - startPoint.X), Math.Abs(endPoint.Y - startPoint.Y))
If size.Width <= 0 OrElse size.Height <= 0 Then
Exit Sub
End If
Dim capture As New Bitmap(size.Width, size.Height)
Dim g As Graphics = Graphics.FromImage(capture)
Try
g.CopyFromScreen(startPoint, Point.Empty, size)
FullSavedScreenshotPath = OutputFolderPath & Format(Now, "dd-MMM-yy hh-mm-ss") & ".png"
capture.Save(FullSavedScreenshotPath, System.Drawing.Imaging.ImageFormat.Png)
ScreenshotImage = capture
Catch ex As Exception
Error_Messages = ("Error capturing screenshot: " & ex.Message)
Finally
g.Dispose()
End Try
Output: