Jump to content

Recommended Posts

Posted

I don't get why the images I take turns up like this, but it seems to me like the screenshot doesn't go from the actual positions specified. It's weird, cause what happends is that when I for example move the mouse over the number 25 on SciTE, the image shows that it's over 19... Anyone knows what I'm doing wrong?

#include <screencapture.au3>
#include <WindowsConstants.au3>

Hotkeyset("{ESC}", "Terminate")

$gui = GUICreate("", 100, 800, 100, 0, $WS_POPUP, $WS_EX_TOPMOST)

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($gui)

GUISetState(@SW_SHOW, $gui)

While 1
    $scr = _ScreenCapture_Capture("",  0, 0, 100, 800)
    $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($scr)
    _WinAPI_DeleteObject($scr)
    _GDIPlus_GraphicsDrawImage($graphics, $bitmap, 0, 0)
WEnd


Func Terminate()
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_Shutdown()
    Exit
EndFunc

 

Posted

@TheNorwegianUser: you have a memory leak in your code!

You must dispose $bitmap!

While 1
    $scr = _ScreenCapture_Capture("",  0, 0, 100, 800)
    $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($scr)
    _WinAPI_DeleteObject($scr)
    _GDIPlus_GraphicsDrawImage($graphics, $bitmap, 0, 0)
    _GDIPlus_ImageDispose($bitmap)
WEnd

Regarding the mouse position: it works on my Win10 notebook properly.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
45 minutes ago, UEZ said:

@TheNorwegianUser: you have a memory leak in your code!

You must dispose $bitmap!

While 1
    $scr = _ScreenCapture_Capture("",  0, 0, 100, 800)
    $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($scr)
    _WinAPI_DeleteObject($scr)
    _GDIPlus_GraphicsDrawImage($graphics, $bitmap, 0, 0)
    _GDIPlus_ImageDispose($bitmap)
WEnd

Regarding the mouse position: it works on my Win10 notebook properly.

Thanks, didn't notice that. It worked fine with a desktop resolution of 1600x900, but not of 1920x1080, so guess the easiest way out is to just change the resolution before running the script.

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