Jump to content

Move pic object


ssamko
 Share

Recommended Posts

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
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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