06-26-2014, 11:28 AM
This is my rather very simple calling code :
Function CaptureImage
Trigger CWci
Function CaptureImage
Trigger CWci

str si.getmacro(getopt(itemid) 1)
if ideb; out "%s : %s" NowT si
;function# int&result flags [hwndmin] [$bmpfile] [RECT&rect] ;;flags: 0 image, 1 color, 2 minimize owner, 4 disable hwndmin, 8 don't restore if ok
;Allows the user to capture an image or a color on the screen.
;Unlike CaptureImageOnScreen, this function interacts with the user, and returns only when the user clicks OK or Cancel or presses Esc.
;If flags contains 1, captures color, else captures image.
;Returns 1 if the user clicks OK and everything goes without errors. Returns 0 otherwise.
;result - variable that will receive color value or bitmap handle. Later the bitmap must be deleted using DeleteObject. Can be 0 if not needed.
;hwndmin - handle of a window to be minimized/restored. Can be 0.
;bmpfile - if used, saves the image to the file. Returns 0 if fails to save. Can be "".
;rect - receives rectangle/point coordinates. Can be 0.
RECT r
_s.Datim
str sout.from("C:\tmp\Image_" _s ".bmp")
int i=CaptureImageOrColor(0 0 0 sout r)
if !i
,_s="Failed to capture"
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,mac "Warning_QM" si 0
,end
int wid hei x y
x=r.left
y=r.top
wid=r.right-r.left
hei=r.bottom-r.top
;out x
;out y
;out wid
;out hei
__MemBmp b.Create(wid hei 1 x y)
int q=OpenClipboard(_hwndqm)
if(q) EmptyClipboard; q=SetClipboardData(CF_BITMAP b.Detach)!0; CloseClipboard
i=rset(sout "ses_last_CI")
if i=0
,_s="You must create a QM registry string value as ''ses_last_CI'' with value data ''***''"
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,mac "Warning_QM" si 0
,end
beeS 500 500
_s.from("Image captured stored to clipboard - also stored to file " sout)
Task_Message sout 0 255 1