Do either of the functions work in dbc enhanced? I don't have it so can't test. What you want to do is possible with dbpro.
Both the functions use the win api, you can find info about the functions at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/functions_in_alphabetical_order.asp
http://www.mentalis.org/apilist/apilist.php
The mouse_click() function is pretty simple. All it does is position the mouse with
SetCursorPos then use
mouse_event to do a left down then left up.
function mouse_click(x as integer, y as integer)
`clicks the mouse at x,y
load dll "user32.dll",1
call dll 1,"SetCursorPos",x,y
call dll 1,"mouse_event",0x2,0,0,0,0 : `leftmouse down
call dll 1,"mouse_event",0x4,0,0,0,0 : `leftmouse up
delete dll 1
`other values
`LEFTDOWN = 0x2
`LEFTUP = 0x4
`MIDDLEDOWN = 0x20
`MIDDLEUP = 0x40
`RIGHTDOWN = 0x8
`RIGHTUP = 0x10
endfunction
The get_screen() function is more complicated. Basically it uses
GetPixel to get the colour value for each pixel and uses it to make a dbpro image memblock which is then made into an image.
function get_screen(image as integer,x1 as integer,y1 as integer,x2 as integer,y2 as integer)
`copies a selected area of the desktop to an image
`the_winch : http://winch.dbspOt.com : [email protected]
local hwnd as integer :`desktop window handle
local dc as integer :`device context for entire desktop window
local x,y,in,pix as integer
local dll_user,dll_gdi as integer :`dll numbers
local mem as integer : `memblock number
`load dlls
dll_user = get_screen_free_dll() : load dll "user32.dll",dll_user
dll_gdi = get_screen_free_dll() : load dll "gdi32.dll",dll_gdi
`get the desktop handle and device context for entire window
hwnd = call dll(dll_user,"GetDesktopWindow")
dc = call dll(dll_user,"GetWindowDC",hwnd)
mem = get_screen_free_memblock() : `get a free memblock to write the image data to
`make sure x2-x1 and y2-y2 is postitive
if x1 > x2 then in = x2 : x2 = x1 : x1 = in
if y1 > y2 then in = y2 : y2 = y1 : y1 = in
`make the memblock used to hold image info
make memblock 1,12+(((x2-x1)*(y2-y1))*4)
write memblock dword 1,0,x2-x1
write memblock dword 1,4,y2-y1
write memblock dword 1,8,32
`fill the memblock with the desktop image
in = 12
for y = y1 to y2-1
for x = x1 to x2-1
pix = call dll(dll_gdi,"GetPixel",dc,x,y) :`get the desktop pixel colour
pix = rgb(rgbb(pix),rgbg(pix),rgbr(pix)) :`windows gives us the colour info in rgb format where dbpro memblocks use bgr so swap r and b arround
write memblock dword mem,in,pix :`write the pixel to the memblock
inc in,4
next x
next y
`convert the memblock to image and cleanup
make image from memblock image,mem
delete memblock mem
delete dll dll_user
delete dll dll_gdi
endfunction
function get_screen_free_memblock()
`finds a free memblock
local i,stop as integer
repeat
inc i
if memblock exist(i) = 0 then stop = 1
until stop = 1
endfunction i
function get_screen_free_dll()
`finds a free dll slot
local i,stop as integer
repeat
inc i
if i < 256 then if dll exist(i)=0 then stop = 1
until stop = 1 or i > 255
if i > 255 then i = 0
endfunction i
I wrote a quick app in dbpro that captures the part of the minesweeper windows with the squares in. Then it works out what each square is an puts the info in an array. The image on the left is image captured from the minesweeper window at the stuff on the right is a textual representation of the info in the array.
http://winch.dbspot.com/temp/mine.png
download
http://winch.dbspot.com/temp/mine.zip
i won't see you in the pit