Jump to content

Strange behavior of _ScreenCapture_CaptureWnd


Go to solution Solved by JensB,

Recommended Posts

Hi World,

I am an AutoIt Newb. I start with a simple task. Starting an app, making some mouse clicks and then saving  a picture of the app. The function to save the picture looks like.

Func Capture($vName, ByRef $sClass)
    Local $hWindow = WinGetHandle($sClass)
    Local $path = @ScriptDir & "\..\Results\" & $vName
    _ScreenCapture_SetBMPFormat(2)
    _ScreenCapture_CaptureWnd($path & ".bmp", $hWindow )
EndFunc

The issue is that the saved picture differs in size dependent on the monitor I use. The app have a screen size of 800x480 pixel (exclusive application borders) . AutoIt Window Info shows me a size of 806x509pixel (with application borders).  My expectation is, when I call _ScreenCapture_CaptureWnd I got an image of that size.

 

I have here an Laptop with a resolution of 1920x1080pixel. Additonally there are 2 Monitors connected. Each with a resolution of 1920x1200. AutoIt Window Info show me a size of my application 806x509pixel on each monitor. But when I execute _ScreenCapture_CaptureWnd() The resulted image differs in size. On the 1920x1200 Monitors I got an image of 802x507pixel, as ecpected. But when I do the same on my 1092x1080pixel monitor then i got an image of 1002x633pixel. It is the same content and same scaling but a bigger picture. 

I modified my capture routine a bit to take the Application width and height into account. With this code I got not the whole picture on my 1092x1080pixel monitor, while I got the whole picture on my 1920x1200Monitors. 

Func Capture($vName, ByRef $sClass)
    Local $hWindow = WinGetHandle($sClass)
    Local $aPos = WinGetPos($sClass)
    Local $path = @ScriptDir & "\..\Results\" & $vName ;& "_w" & $aPos[2] & "_h" & $aPos[3]
    _ScreenCapture_SetBMPFormat(2)
    _ScreenCapture_CaptureWnd($path & ".bmp", $hWindow, 0, 0,$aPos[2],$aPos[3], false )
EndFunc

Does any one knows why _ScreenCapture_CaptureWnd behaves differently? Thank you in advance.

 

Backgound Information: I want to use AutoIt für testing some UIs. And the saved images shall be compared with some referecne picture. Therefore size matters in my case.

 

Link to post
Share on other sites

I have checked the the appliacation screen size with another Screenshot tool (Greenshot) and on my 1092x1080 Monitor the real size of the app is 1002x633pixel. But AutoIt Windows Info shows me 806x509pixel. So it seems that this is not an issue of AutoIt. Windows show the application in different sizes, when moving from one Monitor to another. This happens also with other applications. Does any know why?

Does anyone know how to get an identical screenshot with AutoIt independently of the monitor resolution? Thank you.

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...