Jump to content

Recommended Posts

Posted (edited)

Hello ! 

I have a small problem with taking screen. What I do:

1) I take a screenshot of window(thanks to it's hwnd)

2) I save this picture on desktop

but that saved picture is moved +8px from left and top

is there any GDI function which can move this graphic object immediately after screen-shot on position 0,0 (it means it have to move it -8px top and -8px left)

 

I hope you understand

I would be very thankful for help !

Thnx !

Edited by ssamko
Posted

There are so many screenshot UDFs available on the forum - which one do you use?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)
1 hour ago, water said:

There are so many screenshot UDFs available on the forum - which one do you use?

This one ....can you tell me write why this happens ? 

 

 

Edited by ssamko
Posted

Why don't you use function _ScreenCapture_CaptureWnd that comes with AutoIt?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Right.
I just wanted to ask the right questions to get more information about your problem.
There are many users how know much more about GDI. Hopefully one of them chimes in.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Try once the _ScreenCapture_CaptureWnd instead and you see if the problem is from your used UDF. When it is from you can switch to original, if not show the code you used to save image as desktopimage.

Posted (edited)

I think this is what you're trying to do, shift the captured image to the left 8px and up 8px

#include <GDIplus.au3>
#include <ScreenCapture.au3>
#include <WinApi.au3>

Opt("WinTitleMatchMode", -2)

Global $xOffset = -8
Global $yOffset = -8

_GDIPlus_Startup()
Example()

Func Example()
    Local $hBitmap = _ScreenCapture_CaptureWnd("", WinGetHandle("VLC media player"))
    Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    Local $hBitmap2 = _GDIPlus_BitmapCreateFromScan0(_GDIPlus_ImageGetWidth($hImage) + $xOffset, _GDIPlus_ImageGetHeight($hImage) + $yOffset)
    Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap2)

    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, $xOffset, $yOffset)
    _GDIPlus_ImageSaveToFile($hBitmap2, @DesktopDir & "\Image.png")

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_ImageDispose($hBitmap2)
    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_Shutdown()
EndFunc

 

Edited by InunoTaishou

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
×
×
  • Create New...