There is code by LinearSpoon to do this for Autohotkey 1.x here:
https://www.autohotkey.com/board/topic/121619-screencaptureahk-broken-capturescreen-function-win-81-x64/
The main issue I’m having is that I’m not sure what to use to replace lines like:
VarSetCapacity(mi, 32, 0), Numput(16+A_PtrSize, mi, 0, "uint")
and
VarSetCapacity(si, 16, 0), si := Chr(1)
AHK 2.0 doesn’t have the [VarSetCapacity][1]
command, and the changelog lists it as:
Removed: […]
VarSetCapacity (use a Buffer object for binary data/structs and VarSetStrCapacity for UTF-16 strings)
And it looks like at least si
above needs to be filled with zeroes, then have the ascii character 1 inserted… and I don’t know how to do that.
I think I need to start out by allocating a buffer, something like:
si := Buffer(16, 0)
si := Chr(1)
But won’t the second line override the first, replacing the buffer with a character? The help page on Buffer didn’t make clear how you should write a value into the buffer. Might be Numput()?
For the time being, I’ve just installed the portable version of ImageMagick and executed the external command:
magick screenshot:[0] -crop 100x200+300+400 ssc.png
This creates a 100×200 image, taken from coordinates (300x, 400x). It’s not ideal, but it’s a LOOOOT easier than the alternative.
But an ahk-native way of doing this (well, with gdiplus.dll, so not fully native) would be much nicer, if anyone knows how to port the original v1.x code to 2.x.
2