Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PixelChecksum. Wait until something changes on screen.
#1
How can I do a function to Wait until something (pixels) changes in the region 0,0 to 50,50 ?
#2
Is the image known before? If yes, use scan. If no, also can be used scan but at first needs to capture the image at run time. I have a function for this, if you need.
#3
Can you post the function?
#4
Function CaptureImageOnScreen
Code:
Copy      Help
;/
function# x y wid hei [$saveToBmpFile] [&getHbitmap]

;Captures a rectangle region on the screen.
;Can save the captured image to a bmp file, or get bitmap handle, or store to the clipboard.
;If saveToBmpFile and getHbitmap not used, stores to the clipboard.
;Returns 1 on success, 0 on failure.


;x, y, wid, hei - rectangle coordinates.
;saveToBmpFile - will save to this bmp file. Use "" if don't want to save.
;getHbitmap - int variable that receives bitmap handle. Use 0 if not needed. Later call DeleteObject.


;EXAMPLE
;CaptureImageOnScreen 100 100 200 200



int dcs=GetDC(0) ;;get screen device context
int dc=CreateCompatibleDC(0) ;;create memory device context
int bm=CreateCompatibleBitmap(dcs wid hei) ;;create bitmap
int oldbm=SelectObject(dc bm) ;;select it into the memory dc
BitBlt(dc 0 0 wid hei dcs x y SRCCOPY) ;;copy from screen dc to memory dc

int r(1) action

if(len(saveToBmpFile)) ;;save
,action|1
,r=SaveBitmap(bm saveToBmpFile)
,
if(&getHbitmap and r) ;;get HBITMAP
,action|2
,getHbitmap=bm
,
if(!action) ;;store to the clipboard
,r=OpenClipboard(_hwndqm)
,if(r)
,,EmptyClipboard
,,r=SetClipboardData(CF_BITMAP bm)!0
,,CloseClipboard

;release memory
ReleaseDC(0 dcs)
SelectObject(dc oldbm)
DeleteObject(dc)
if(action&2=0) DeleteObject(bm)

ret r
#5
Ok. Thanks.
#6
Function WaitForRectImageChange
Code:
Copy      Help
;/
function ^wt RECT&r

;Waits until something changes in the specified rectangle on the screen.

;wt - max wait time, s. Error on timeout. Use 0 to wait forever.
;r - variable that contains screen coordinates of the rectangle.


;EXAMPLE
;RECT r
;r.left=100; r.top=100; r.right=r.left+100; r.bottom=r.top+100
;WaitForRectImageChange 0 r
;mes "changed"



GdiObject bm
if(!CaptureImageOnScreen(r.left r.top r.right-r.left r.bottom-r.top "" bm)) end ES_FAILED
int t1=GetTickCount
rep
,0.1
,if(!scan(bm 0 r 0)) break
,if(wt and GetTickCount-t1>=wt*1000) end "wait timeout"
#7
Thanks again.

This is what I was looking for.


Forum Jump:


Users browsing this thread: 1 Guest(s)