Jump to content

Recommended Posts

Posted (edited)

Description:

This is an UDF to get a pixel from the memory. You first take a screenshot into memory, then use the pixel grabbing function as many times as you like, then call the destroy function. Please note that all of these functions are designed towards maximum performance. This means that nothing is actually released automatically so that the end-user can keep maximum control over what happens.

Author:

Original method: Greenseed

UDF: Manadar

Download:

Example:

#include <_PixelGetColor.au3>
#include <Misc.au3>

$hDll = DllOpen("gdi32.dll")

$vDC = _PixelGetColor_CreateDC($hDll)

$vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,@DesktopWidth,@DesktopHeight,$hDll)

; click left mouse button to exit
While Not _IsPressed(0x01)
    $aPos = MouseGetPos()
    $sColor = _PixelGetColor_GetPixel($vDC, $aPos[0],$aPos[1], $hDll)

    ToolTip("The color under your mouse is: " & $sColor, $aPos[0]+3, $aPos[1]+3, "_PixelGetColor_GetPixel return",$hDll)
WEnd

_PixelGetColor_ReleaseRegion($vRegion)

_PixelGetColor_ReleaseDC($vDC,$hDll)

DllClose($hDll)

Benefits of using this method:

It's faster for capturing more pixels at once.

All the pixels can be captured at once, then read at your convenience anywhere in the script. You can capture multiple screens at once and compare them.

No problems with Vista (Aero) or Windows 7.

Drawbacks:

It's harder to implement.

_PixelGetColor.au3

Example.au3

Edited by Manadar
Posted

Nice script :D I'll definitly gonna use this one for my image-to-text prog.

But... you should alter your example script which is in your post between the codebox tags... because this one isn't working.

You haven't used any vars their on which screen to use the pixelgetcolor..

Neo

[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Posted

Nice script :P I'll definitly gonna use this one for my image-to-text prog.

But... you should alter your example script which is in your post between the codebox tags... because this one isn't working.

You haven't used any vars their on which screen to use the pixelgetcolor..

Neo

Thanks, I forgot to remove it. :D It was on of the older versions until I realized to not use any global variables in the include.
Posted (edited)

Amazing. Just amazing, I needed to do a PixelGetColour for about 190 (x,y) positions, was taking about 5-6 secs using the AutoIt function.

This is less than a second - brilliant.

One thing, I suggest creating some way of getting it to grab only a specific client window or window area, I fixed the problem by getting the window position from Au3Info and setting it up like this, with $win_title being your windows title.

$windowinfo = WinGetPos ( $win_title)
    $vRegion = _PixelGetColor_CaptureRegion($vDC, $windowinfo[0],$windowinfo[1],@DesktopWidth,@DesktopHeight)oÝ÷ Ù8b³¥ÚÚrKa{§v)¢È­ÚÚ'(+i·ë¢kazÚ)çí¡ûa{§vuا©è}û¶X¤zØb±«­¢+ØÀÌØíÙI¥½¸ô}A¥á±Ñ
½±½É}
ÁÑÕÉI¥½¸ ÀÌØíÙ°ÀÌØíÝ¥¹½Ý¥¹½lÁt¬Ì°ÀÌØíÝ¥¹½Ý¥¹½lÅt¬È̱ͭѽÁ]¥Ñ ±Í­Ñ½Á!¥¡Ð¤

With the offsets being - $windowinfo[0]+3,$windowinfo[1]+23

Will fix it to client pixel co-ord mode for vista, not sure what the offsets are for XP.

Regardless, brilliant work, my Script wouldnt be working without it biggrin.gif

Edited by marscom
Posted

pritty good work manadar *handclap*

but is it fast enough to capture for example a movie or a game?

i suppose that taking a screenshot takes some time and calculationg where the pixels are less time, so now the screenshot function is the bottleneck?

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Posted (edited)

Somebody needs to make a Guitar Hero bot with this. =]]] I could write it pretty easily but my computer can't run the game :) If somebody were to get me the pixel coords and hex colors of the note however, I could write the routines petty easily/quickly.

Edit: I would also need what keys to send to for the frets and strum, etc.

Edited by fear1313

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Posted

@JRSmile, I am not quite sure where the bottle neck is currently... It's probably at AutoIt's limitation to call these DLL's very fast since the other components are so fast.

Somebody needs to make a Guitar Hero bot with this. =]]] I could write it pretty easily but my computer can't run the game :) If somebody were to get me the pixel coords and hex colors of the note however, I could write the routines petty easily/quickly.

Edit: I would also need what keys to send to for the frets and strum, etc.

http://www.autoitscript.com/forum/index.php?showtopic=62681 :)

Posted

@JRSmile, I am not quite sure where the bottle neck is currently... It's probably at AutoIt's limitation to call these DLL's very fast since the other components are so fast.

http://www.autoitscript.com/forum/index.php?showtopic=62681 :)

If your going to repeatedly call the dll, you might want to add a optional param of the dll, default to "dll.name" that way you can open with DllOpen and pass the handle in that should speed it up some.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted (edited)

@JRSmile, I am not quite sure where the bottle neck is currently... It's probably at AutoIt's limitation to call these DLL's very fast since the other components are so fast.

http://www.autoitscript.com/forum/index.php?showtopic=62681 :)

Still sick, but took a look at it, see what you think of the modifications: PixelGetColor.au3, modified example: _PixelGe...GetPixel.au3

Each header that has a Yes for Example is what would be expected to have examples for being all but 1 function was used in your example.

Edit: Removed Attachments

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted (edited)

Still sick, but took a look at it, see what you think of the modifications: , modified example:

Each header that has a Yes for Example is what would be expected to have examples for being all but 1 function was used in your example.

Very good! I like what you did with all the _WinAPI functions, I had no idea. I noticed you didn't use $hDll in the _PixelGetColor_GetPixel function, but I see you meant to use it in the _PixelGetColor_GetPixelRaw function.

I have uploaded these files in the initial post. I still have to update the headers now and write an example for _PixelGetColor_GetPixelRaw.

Edited by Manadar
Posted

Very good! I like what you did with all the _WinAPI functions, I had no idea. I noticed you didn't use $hDll in the _PixelGetColor_GetPixel function, but I see you meant to use it in the _PixelGetColor_GetPixelRaw function.

I have uploaded these files in the initial post. I still have to update the headers now and write an example for _PixelGetColor_GetPixelRaw.

I meant to pass it on in the Call to _PixelGetColor_GetPixelRaw from _PixelGetColor_GetPixel, missed adding that parameter in.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

  • 3 weeks later...
  • 2 months later...
Posted

I really need this function now, and I have no time to do it myself. Please upload it again Madanar :( Thx if you will do it !!

p.s-Oh! and also big THX for making all this stuff :)

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
  • Recently Browsing   0 members

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