I've made an AutoHotkey script to click some banners, and it sends me the photos on Telegram of the clicks it makes. Of course, my x1,y1,x2,y2 coordinates to crop the screenshot are variables and calculated. I've issues with coordinates with ScreenCapture, And issues with mouse cursor with GDI+
In GDI+ works very well, but i don't find any method to capture the mouse, if not replacing it with a picture. (maybe... but it's a bit tricky because i need the exact point where it clicks).
CaptureScreen instead give the possibility to capture the mouse, but I have problems with the x1,x2,y1,y2 variables. Tried in different ways with no chances! How this can be solved? My code Below.
With GDI+
Here's the working code:
picx := 150, picy := 150, picx2 := 400, picy2 := 400
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen( picx "|" picy "|" picx2 "|" picy2 )
Gdip_SaveBitmapToFile(snap, "Shot.png")
Gdip_DisposeImage(snap)
With CaptureScreen.ahk
F1::
MouseGetPos, x, y
mouseareax := 150
mouseareay := 250
picx := x-mouseareax
picy := y-mouseareax
picx2 := x+mouseareax
picy2 := y+mouseareay
if (picx < 0) {
picx2 := picx2 - picx
picx := 0
} else if (picx2 > A_ScreenWidth ){
picx := picx - (picx2 - A_ScreenWidth)
picx2 := 0
}
if (picy < 0) {
picy2 := picy2 - picy
picy := 0
} else if (picy2 > A_ScreenHeight ){
picy := picy - (picy2 - A_ScreenHeight)
picy2 := 0
}
capturecoords := """" picx ", " picy ", " picx2 ", " picy2 """"
msgbox, %capturecoords%
msgbox, CaptureScreen( %capturecoords%, 1, "screen.png")
First Msgbox:
Second Masgbox:
Result: The file is not generated.
Note: The script make care of the screen size, so that in the corners the image has always the same dimensions, and when not in the corners, the mouse is centered to the image (for a good zooming).
Tried also with:
msgbox, CaptureScreen( "%picx%, %picy%, %picx2%, %picy2%", 1, "screen.png")
it gives exact syntax (as second msgbox image), but does not work.

