Jump to content

_ScreenCapture_CaptureWnd function taking different snap on Window 11


Recommended Posts

try: 

#AutoIt3Wrapper_UseX64=n
DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) 

at the beginning of your script and let me know. That may be all you need.

For more information go to "Tester needed ^^"

Edit: Might as well give you running code: ( ain't working that good )

Spoiler
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_HiDpi=y
DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; lazy me. Use something better here  ;-)

#include <ScreenCapture.au3>

Example()

Func Example()
    ; Retrieve the position as well as height and width of the active window.
    Local $aPos = WinGetPos("[ACTIVE]")

    ; Display the array values returned by WinGetPos.
    ConsoleWrite(WinGetTitle("[ACTIVE]") & @CRLF)
    ConsoleWrite("X-Pos: " & $aPos[0] & " / " & _
            "Y-Pos: " & $aPos[1] & " / " & _
            "Width: " & $aPos[2] & " / " & _
            "Height: " & $aPos[3] & @CRLF)

    FileDelete(@MyDocumentsDir & "\GDIPlus_Image.jpg")
    _ScreenCapture_CaptureWnd(@MyDocumentsDir & "\GDIPlus_Image.jpg", WinGetTitle("[ACTIVE]"))
;~  _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.jpg", $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3])
    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

 

and the reason is: something is funky on x64 using "_ScreenCapture_Capture()".
"_ScreenCapture_CaptureWnd()" is ok.

...it may need a ticket.

Edit2: No need for a ticket, just a better example :( 

#AutoIt3Wrapper_UseX64=y ; no longer matters
#AutoIt3Wrapper_Res_HiDpi=n

;~ DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; nope !. Use the UDF from below
#include "_WinAPI_DPI.au3" ; https://www.autoitscript.com/forum/topic/210604-tester-needed/?do=findComment&comment=1522028

#include <ScreenCapture.au3>

Example()

Func Example()

    ; ..snippet from https://www.autoitscript.com/forum/topic/210604-tester-needed/?do=findComment&comment=1522028
    Local $AWARENESS
    Switch @OSBuild
        Case 9200 To 13999
            $AWARENESS = $DPI_AWARENESS_PER_MONITOR_AWARE
        Case @OSBuild > 13999
            $AWARENESS = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
    EndSwitch
    _WinAPI_SetDPIAwareness($AWARENESS, 2)


    ; Retrieve the position as well as height and width of the active window.
    Local $aPos = WinGetPos("[ACTIVE]")

    ; Display the array values returned by WinGetPos.
    ConsoleWrite(WinGetTitle("[ACTIVE]") & @CRLF)
    ConsoleWrite("X-Pos: " & $aPos[0] & " / " & _
            "Y-Pos: " & $aPos[1] & " / " & _
            "Width: " & $aPos[2] & " / " & _
            "Height: " & $aPos[3] & @CRLF)

    FileDelete(@MyDocumentsDir & "\GDIPlus_Image.jpg")
;~  _ScreenCapture_CaptureWnd(@MyDocumentsDir & "\GDIPlus_Image.jpg", WinGetTitle("[ACTIVE]"))
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.jpg", $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3])
    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

 

Edited by argumentum
oops

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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...