Jump to content

Screen capture mouse icon


Rhyono
 Share

Recommended Posts

Can you make some sense of this? I think this is the idea you are after.

$hscreen= _ScreenCapture_Capture("",$MGP[0]-3,$MGP[1],$MGP[0]+24,$MGP[1]+31,True)
$hbmpscreen= _GDIPlus_BitmapCreateFromHBITMAP($hscreen)
;free the handle
_WinAPI_DeleteObject($hscreen)
for $y= 0 to $h
 for $x= 0 to $w
  if _GDIPlus_BitmapGetPixel($hbmpscreen, $x, $y)= $pixelcolor then
   $pixelmatch+= 1
  endif
 next
next
_GDIPlus_BitmapDispose($hbmpscreen)

Get GDIP here (gdiPlus)

Edited by Xandy
Link to comment
Share on other sites

When my code wasn't working right, I turned to the example of _GDIPlus_BitmapGetPixel, modified the code, and...

#include <GDIP.au3> 
#include <ScreenCapture.au3>
Opt("MustDeclareVars", 1)

_Example()

Func _Example()
Local $hBmp, $hBitmap, $iColor, $MGP

; Pause
Sleep(3000)

; Initialize GDI+
_GDIPlus_Startup()

$MGP = MouseGetPos()
$hBmp = _ScreenCapture_Capture("",$MGP[0]-3,$MGP[1],$MGP[0]+24,$MGP[1]+31,True)
; Create GDI+ Bitmap object from GDI Bitmap object
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
$iColor = _GDIPlus_BitmapGetPixel($hBitmap, 10, 14)

MsgBox(0x40, "Color", "Bitmap Pixel Color at [10, 14] is: 0x" & Hex($iColor,6))

; Clean up
_GDIPlus_ImageDispose($hBitmap)
_WinAPI_DeleteObject($hBmp)

; Uninitialize GDI+
_GDIPlus_Shutdown()
EndFunc

There we go.

Edited by Rhyono
Link to comment
Share on other sites

#include <ScreenCapture.au3>
#include <GDIP.au3>
_gdiplus_startup()

Sleep(3000)
$MGP = MouseGetPos()
$hscreen= _ScreenCapture_Capture("",$MGP[0]-3,$MGP[1],$MGP[0]+24,$MGP[1]+31,True)
$hbmpscreen= _GDIPlus_BitmapCreateFromHBITMAP($hscreen)
;free the handle
_WinAPI_DeleteObject($hscreen)
$color = _GDIPlus_BitmapGetPixel($hbmpscreen, 10, 14);
MsgBox(0,"",Hex($color,6));
_GDIPlus_BitmapDispose($hbmpscreen)

_GDIPlus_ShutDown ()

returns msgbox F0F4F9 for me on XP 32bit

on vista and win_7 you may need to compile then tell the exe to run in compatibly mode for XP and disable the desktop composition in the comparability tab.

Those are things that I have done in the past for pixel detection.

Edited by Xandy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...