Jump to content

Function _ScreenCapture_Capture does not work properly


Recommended Posts

I use _ScreenCapture_Capture function for taking a screenshot with cursor located within browser window. But cursor position on the screenshot is misaligned. Its location is shifted about 20px left and 20px up.  What is the reason of this issue?

Link to comment
Share on other sites

How did you determine what the coordinates for the _ScreenCapture_Capture() should be?  If you used the Au3Info tool, which coordinate mode did you use?  If you are using MouseGetPos(), then make sure that you are using the correct MouseCoodMode option.

Edited by TheXman
Link to comment
Share on other sites

15 hours ago, Nine said:

What is your scaling ?  If it is different than 100%. Try setting browser and windows at 100%, see if it solves it.

Checked once more for the paint window. The result is the same as for the browser

 

screenshot bug.png

Link to comment
Share on other sites

  • Developers
1 hour ago, Vitaliy4us said:

Checked once more for the paint window. The result is the same as for the browser

... and the answers to the asked questions are?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

On 7/11/2019 at 10:02 PM, Bert said:

Post your code so we can see what is happening. I suspect your coordinate mode setting is wrong.

#include <ScreenCapture.au3>

HotKeySet("+s", "TakeAScreenshot") ;Shift+s
HotKeySet("{ESC}", "Terminate")

While 1
   Sleep(100)
WEnd

Func Terminate()
   Exit
EndFunc

Func TakeAScreenshot()
   _ScreenCapture_Capture ("Screenshot with cursor.jpg")
   ;Exit
EndFunc

 

Link to comment
Share on other sites

Link to comment
Share on other sites

On 7/15/2019 at 5:06 PM, Nine said:

Using your own code with your own picture, you can see that it works perfectly...

I still believe it is a question of scaling.

 

Yes, I agree with you. But the question is why this scaling happens. If I make two screenshots: one with the PrnScn button and another with the script I get different results. Those made with the button is not scaled and script made screenshot is really scaled...

Link to comment
Share on other sites

This is the code included in the ScreenCapture.au3 UDF about location of cursor :

Local $aCursor = _WinAPI_GetCursorInfo()
        If Not @error And $aCursor[1] Then
            $bCursor = True ; Cursor info was found.
            Local $hIcon = _WinAPI_CopyIcon($aCursor[2])
            Local $aIcon = _WinAPI_GetIconInfo($hIcon)
            If Not @error Then
                _WinAPI_DeleteObject($aIcon[4]) ; delete bitmap mask return by _WinAPI_GetIconInfo()
                If $aIcon[5] <> 0 Then _WinAPI_DeleteObject($aIcon[5]); delete bitmap hbmColor return by _WinAPI_GetIconInfo()
                _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon)
            EndIf
            _WinAPI_DestroyIcon($hIcon)
        EndIf

If you wish to find where the function is in error, you could modify to check where the info gets defective...

Edited by Nine
Link to comment
Share on other sites

31 minutes ago, Nine said:

This is the code included in the ScreenCapture.au3 UDF about location of cursor :

Local $aCursor = _WinAPI_GetCursorInfo()
        If Not @error And $aCursor[1] Then
            $bCursor = True ; Cursor info was found.
            Local $hIcon = _WinAPI_CopyIcon($aCursor[2])
            Local $aIcon = _WinAPI_GetIconInfo($hIcon)
            If Not @error Then
                _WinAPI_DeleteObject($aIcon[4]) ; delete bitmap mask return by _WinAPI_GetIconInfo()
                If $aIcon[5] <> 0 Then _WinAPI_DeleteObject($aIcon[5]); delete bitmap hbmColor return by _WinAPI_GetIconInfo()
                _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon)
            EndIf
            _WinAPI_DestroyIcon($hIcon)
        EndIf

If you wish to find where the function is in error, you could modify to check where the info gets defective...

No errors, cursor coordinates remain the same from the beginning until calling draw icon function. So cursor is captured ok, but the screen image underneath the cursor shrinks.

Link to comment
Share on other sites

7 minutes ago, Vitaliy4us said:

So cursor is captured ok, but the screen image underneath the cursor shrinks.

If the image shrinks, should the cursor be located down-right ?  In you case, it is up-left, like if the image expands, no ?   What version of windows and autoit are you using ?

Link to comment
Share on other sites

14 minutes ago, Nine said:

If the image shrinks, should the cursor be located down-right ?  In you case, it is up-left, like if the image expands, no ?   What version of windows and autoit are you using ?

I use Win10 and the last version of Autoit v. 3.3.14

Edited by Vitaliy4us
Link to comment
Share on other sites

Link to comment
Share on other sites

16 minutes ago, Nine said:

Just curious, could you look at this :

Go to the Windows Start Menu.

Choose Settings.

Select System.

Select Display.

Look for Scale and layout.   What is the % ?

125% (recommended). Also I checked image sizes for the both: PrnScn screenshot and Script Screenshot. The results are:

btn - 1920x1080 resolution 120
script - 1536x864 resolution 96

Link to comment
Share on other sites

9 minutes ago, Nine said:

Could you put 100% instead and try your script again...

Yes, now it looks ok, but too small. Thanks. By the way, it should be the reason why the screenshot made by the script is cropped while captured with the button is ok. 

Edited by Vitaliy4us
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...