; 【官网有详细示例】https://github.com/thqby/ahk2_lib/tree/master/wincapture #Requires AutoHotkey v2.0 #Include <wincapture> ; WGC := wincapture.WGC() ; screen := WGC.capture([0, 0, A_ScreenWidth, A_ScreenHeight]) ; WGC := wincapture.WGC(WinExist("ahk_class AHKEditor")) ; 有窗口边框线 ; screen := WGC.capture() ; ; screen.show() ; ExitApp dwm := wincapture.DWM(A_LineFile "\..\Lib\" (A_PtrSize * 8) "bit\wincapture.dll") bmpBuf := dwm.capture(WinExist("Program Manager ahk_class Progman ahk_exe explorer.exe")) ; MsgBox "第7行:" bmpBuf.ptr bmpBuf.show() ; 自带的显示功能 ; MsgBox bmpBuf.getHexColor(11, 222) ; hBitmap := bmpBuf.HBITMAP(True) ; 不少图像需要True,转24位图 ; ui := Gui() ; ui.AddPicture(, "HBITMAP:" hBitmap.ptr) ; ui.Show() Sleep 5000 ExitApp revice(pdata, pitch, sw, sh, tick) { if tick && pdata { bb := BitmapBuffer(pdata, pitch, sw, sh) ; find picture t3 := A_TickCount if bb.findPic(&x,&y, t := BitmapBuffer.loadPicture("1.bmp")) t3 := A_TickCount - t3, fillcolor(x, y, 0xff0000ff, 40) ; get pixel color color := bb[Random(0, A_ScreenWidth - 1), Random(0, A_ScreenHeight - 1)] ; search pixel t1 := A_TickCount if bb.findColor(&x, &y, color) t1 := A_TickCount - t1, fillcolor(x, y, 0xff00ff00) ; search multi pixel combination arr := [], x := Random(0, A_ScreenWidth), y := Random(0, A_ScreenHeight) loop 9 { xx := Random(-x, A_ScreenWidth - x - 1), yy := Random(-y, A_ScreenHeight - y - 1) arr.Push([bb[x + xx, y + yy], xx, yy]) } t2 := A_TickCount if bb.findMultiColors(&x, &y, arr) { t2 := A_TickCount - t2 for a in arr fillcolor(a[2] + x, a[3] + y, 0xffff0000) } ; preview bb.show("src") t.show("dst") MsgBox "findColor: " t1 "ms`nfindMultiColors: " t2 "ms`nfindPic: " t3 "ms" } fillcolor(x, y, color, r := 20) { loop r { i := A_Index - 1 loop r bb[x + i, y + A_Index - 1] := color } } }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)