Get or Read Pixel from Memory UDF - PixelGetColor .au3
#21
Posted 14 May 2008 - 05:33 PM
#22
Posted 15 May 2008 - 10:21 AM
I believe it was:I have it uploaded (Thanks to NeoFoX) but the example still is missing. I'm waiting for Gary to reply to this thread, see if he still has a version of the example.
#include <PixelGetColor.au3> #include <Misc.au3> $vDC = _PixelGetColor_CreateDC() $vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,@DesktopWidth,@DesktopHeight) $hDll = DllOpen("gdi32.dll") ; 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") WEnd DllClose($hDll) _PixelGetColor_ReleaseRegion($vRegion) _PixelGetColor_ReleaseDC($vDC)
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
#23
Posted 24 June 2008 - 01:48 AM
This will not work because the function "_PixelGetColor_GetPixel" accepts two parameters not 4, and Autoit throws an error saying wrong number of parameters. Anyone have a working example, or know what to change?I believe it was:
AutoIt#include <PixelGetColor.au3> #include <Misc.au3> $vDC = _PixelGetColor_CreateDC() $vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,@DesktopWidth,@DesktopHeight) $hDll = DllOpen("gdi32.dll") ; 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") WEnd DllClose($hDll) _PixelGetColor_ReleaseRegion($vRegion) _PixelGetColor_ReleaseDC($vDC)
#24
Posted 24 June 2008 - 03:30 AM
#include <PixelGetColor.au3> #include <Misc.au3> $vDC = _PixelGetColor_CreateDC() $vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,@DesktopWidth,@DesktopHeight) $hDll = DllOpen("gdi32.dll") ; click left mouse button to exit While Not _IsPressed(0x01) $aPos = MouseGetPos() $sColor = _PixelGetColor_GetPixel($vDC, $aPos[0],$aPos[1]) ToolTip("The color under your mouse is: " & $sColor, $aPos[0]+3, $aPos[1]+3, "_PixelGetColor_GetPixel return") WEnd DllClose($hDll) _PixelGetColor_ReleaseRegion($vRegion) _PixelGetColor_ReleaseDC($vDC)
Edited by xekon, 24 June 2008 - 03:30 AM.
#25
Posted 24 June 2008 - 05:24 PM
Fixed in last update.
#26
Posted 24 June 2008 - 05:37 PM
This shows AutoIt in it's pure slowness.
#include <GUIConstants.au3> #include <_PixelGetColor.au3> ; MAGIC! ; Full topic here: <a href='http://www.autoitscript.com/forum/index.php?showtopic=63318' class='bbc_url' title=''>http://www.autoitscript.com/forum/index.php?showtopic=63318</a> Global $Aimbot = 0, $vRegion Opt("MouseClickDelay", 0) Opt("MouseClickDownDelay", 0) HotKeySet("{Space}", "ToggleAimbot") $oGame = ObjCreate ("ShockwaveFlash.ShockwaveFlash.1") $GameForm = GUICreate("Aimbot Proof of Concept", 820, 660, 0, 0) $GUIActiveX = GUICtrlCreateObj ($oGame, 10, 10, 800, 580) $exitbutton = GUICtrlCreateButton("Exit", 704, 624, 89, 25) GUICtrlCreateLabel("Hit [Space] to toggle the aimbot", 16, 608, 300, 17) $status = GUICtrlCreateLabel("Aimbot Status: Off", 16, 624, 500, 33) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") With $oGame .bgcolor = "#000000" .Movie = 'http://farm.addictinggames.com/D78AQSAKQLQWI9/2025.swf' .ScaleMode = 2 .Loop = True .wmode = "Opaque" EndWith GUICtrlCreateLabel("Aimbot Options:", 340, 608, 78, 17) $hDll = DllOpen("gdi32.dll") $vDC = _PixelGetColor_CreateDC($hDll) GUISetState() While 1 If $Aimbot = 1 Then; Auto-Aim + Autoshoot $vRegion = _PixelGetColor_CaptureRegion($vDC, 10,10,800,500,$hDll) For $x = 0 to 790 For $y = 0 to 490 $sColor = _PixelGetColor_GetPixel($vDC, $x, $y, $hDll) If $sColor = "FF9986" Then MouseClick('left', $x, $y, 1, 0) Send("r") EndIf Next Next EndIf $msg = GUIGetMsg() Switch $msg Case $exitbutton, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _PixelGetColor_ReleaseRegion($vRegion) _PixelGetColor_ReleaseDC($vDC,$hDll) DllClose($hDll) Exit Func ToggleAimbot() If $Aimbot < 1 Then $Aimbot = $Aimbot + 1 Else $Aimbot = 0 EndIf Select Case $Aimbot = 0 GUICtrlSetData($status, "Aimbot Status: Off") Case $Aimbot = 1 GUICtrlSetData($status, "Aimbot Status: AutoFind + AutoShoot") EndSelect EndFunc
#27
Posted 02 August 2008 - 09:41 PM
#28
Posted 02 August 2008 - 11:40 PM
Somewhat like in the example above, only you'd have to write your own algorithm for determining the difference between two colors.Hey, although this does work for a single pixel how would you use this to search for range or variations as you would with PixelSearch
I have something like it on my computer, but it isn't AutoIt. I hope you can understand it and convert it into AutoIt.
ColorDiff.R = Color1.R - Color2.R ColorDiff.G = Color1.G - Color2.G ColorDiff.B = Color1.B - Color2.B if (ColorDiff.R < 0) then ColorDiff.R *= -1 end if (ColorDiff.G < 0) then ColorDiff.G *= -1 end if (ColorDiff.B < 0) then ColorDiff.B *= -1 end ColorDifference = ColorDiff.R + ColorDiff.G + ColorDiff.B if (ColorDifference < 100) then -- 100 is the sensitivity here -- do stuff end
#29
Posted 03 August 2008 - 12:08 AM
#30
Posted 03 August 2008 - 06:44 AM

#31
Posted 02 March 2009 - 02:39 AM
Here's a test script:
#include <_PixelGetColor.au3> #include <Misc.au3> $init=TimerInit() For $x=1 To 320 For $y=1 To 240 PixelGetColor($x,$y) Next Next MsgBox(0,"","100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($x * $y)) $hDll = DllOpen("gdi32.dll") $vDC = _PixelGetColor_CreateDC($hDll) $vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,320,240,$hDll) $init=TimerInit() For $x=1 To 320 For $y=1 To 240 _PixelGetColor_GetPixel($vDC, $x,$y, $hDll) Next Next MsgBox(0,"","100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($x * $y))
Upon running it, I get the following:
PixelGetColor():
Time: ~10563 ms
Avg: ~0.13655 ms
_PixelGetColor_CreateDC():
Time: ~47431 ms
Avg: ~0.61312 ms
Am I doing something wrong? Would love to have a faster alternative to PixelGetColor.
#32
Posted 02 March 2009 - 08:26 AM
Your results are horrible though:
PixelGetColor():
Time: ~1208 ms
Avg: ~0.0157 ms
_PixelGetColor_CreateDC():
Time: ~3328 ms
Avg: ~0.0430 ms
#33
Posted 02 March 2009 - 12:14 PM
#34
Posted 18 March 2009 - 09:54 AM
Compatibility with previous versions is "non-existent" also known as script breaking.
I still recommend using the _PixelGetColor_GetRaw function and rewriting your algorithm to use BGR.
PixelGetColor
100%: 1311.44265542129
Average: 0.0169525595608418
_PixelGetColor_GetPixel
100%: 4878.42141948209
Average: 0.0630606773946629
_PixelGetColor_GetPixelRaw
100%: 2670.78301851213
Average: 0.0345238347952256
Test script:
#include <_PixelGetColor.au3> #include <Misc.au3> $init=TimerInit() For $x=1 To 320 For $y=1 To 240 PixelGetColor($x,$y) Next Next ConsoleWrite("[b]PixelGetColor[/b]" & @CRLF & "100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($x * $y) & @CRLF & @CRLF) $hDll = DllOpen("gdi32.dll") $vDC = _PixelGetColor_CreateDC() $vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,320,240) $init=TimerInit() For $x=1 To 320 For $y=1 To 240 _PixelGetColor_GetPixel($vDC, $x,$y, $hDll) Next Next ConsoleWrite("[b]_PixelGetColor_GetPixel[/b]" & @CRLF & "100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($x * $y) & @CRLF & @CRLF) DllClose($hDll) $hDll = DllOpen("gdi32.dll") $vDC = _PixelGetColor_CreateDC() $vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,320,240) $init=TimerInit() For $x=1 To 320 For $y=1 To 240 _PixelGetColor_GetPixelRaw($vDC, $x,$y, $hDll) Next Next ConsoleWrite("[b]_PixelGetColor_GetPixelRaw[/b]" & @CRLF & "100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($x * $y) & @CRLF) DllClose($hDll)
Edited by Manadar, 18 March 2009 - 10:03 AM.
#35
Posted 09 April 2009 - 06:37 AM
Test for 300x300 area:
PixelGetColor
100%: 1295.54316743593
Average: 0.00516157297825462
PixelSearch
100%: 3.46136755706857
Average: 1.39017151978103e-005
SOLUTION: AutoIt team, PLEASE provide more of simple built-in functions!
#36
Posted 09 April 2009 - 07:29 AM
To be more specific, this gets the pixel from memory, not from the screen, meaning you can grab screenshots from minimized applications, effectively enabling you to automate as many concurrent instances as your hardware can handle. This script is pure gold, and your criticism is tripe. Think, or at least read, before you post next time.
Edited by JRowe, 09 April 2009 - 07:30 AM.
However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator
#37
Posted 09 April 2009 - 09:37 PM
Can you imagine using it for a game? Something that needs to respond to a pixel faster then 1 second delay?
I know there will be new pixel search addition in the 3.3.1.0? ( search pixel starting from left, right, bottom and top)
Pixel functions are VERY CPU intensive because there are a lot of pixels to deal with. The best solution is to have built in algorithms that run C++! they are simple yet do a lot of work x1000 faster.
Edited by dexto, 10 April 2009 - 12:56 AM.
#38
Posted 11 May 2009 - 03:24 AM
_PixelGetColor_CaptureRegion 100%: 6.34111961370737 _PixelGetColor_GetPixelRaw 100%: 110123.193945799 Average: 0.0623316217440469
#include <_PixelGetColor.au3> #include <Misc.au3> Global $w=@DesktopWidth Global $h=@DesktopHeight $hDll = DllOpen("gdi32.dll") $vDC = _PixelGetColor_CreateDC() $init = TimerInit() $vRegion = _PixelGetColor_CaptureRegion($vDC, 0, 0, $w, $h) ConsoleWrite("_PixelGetColor_CaptureRegion" & @CRLF & "100%: " & TimerDiff($init) & @CRLF & @CRLF) Dim $pix[$w][$h] $init = TimerInit() For $x = 1 To $w For $y = 1 To $h $pix[$x-1][$y-1]=_PixelGetColor_GetPixelRaw($vDC, $x, $y, $hDll) Next Next ConsoleWrite("_PixelGetColor_GetPixelRaw" & @CRLF & "100%: " & TimerDiff($init) & @CRLF & "Average: " & TimerDiff($init) / ($x * $y) & @CRLF) DllClose($hDll)
#39
Posted 11 May 2009 - 03:50 AM
http://msdn.microsoft.com/en-us/library/dd145049(VS.85).aspxMemory Device Contexts
To enable applications to place output in memory rather than sending it to an actual device, use a special device context for bitmap operations called a memory device context. A memory DC enables the system to treat a portion of memory as a virtual device. It is an array of bits in memory that an application can use temporarily to store the color data for bitmaps created on a normal drawing surface. Because the bitmap is compatible with the device, a memory DC is also sometimes referred to as a compatible device context.
The memory DC stores bitmap images for a particular device. An application can create a memory DC by calling the CreateCompatibleDC function.
The original bitmap in a memory DC is simply a placeholder. Its dimensions are one pixel by one pixel. Before an application can begin drawing, it must select a bitmap with the appropriate width and height into the DC by calling the SelectObject function. To create a bitmap of the appropriate dimensions, use the CreateBitmap, CreateBitmapIndirect, or CreateCompatibleBitmap function. After the bitmap is selected into the memory DC, the system replaces the single-bit array with an array large enough to store color information for the specified rectangle of pixels.
When an application passes the handle returned by CreateCompatibleDC to one of the drawing functions, the requested output does not appear on a device's drawing surface. Instead, the system stores the color information for the resultant line, curve, text, or region in the array of bits. The application can copy the image stored in memory back onto a drawing surface by calling the BitBlt function, identifying the memory DC as the source device context and a window or screen DC as the target device context.
Is it possible to access that array directly?
#40
Posted 11 May 2009 - 06:32 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users




