The Bytecode Club
Log inJoin the club
Video Game Reverse Engineering

Pixel information tool

Started by Snarg · Feb 8, 2015

17 replies305,532 views
Feb 8, 2015#1

Hello,

Quick question for the developers: Do you have a tool you use to retrieve pixel information from the game screen? Mainly X/Y (taking into account the offset) and color information? If so, would you be willing to share it?

Thank you for your time and I hope to hear back from you soon.

Feb 8, 2015#2

Autoit has an Information Window, you can use that to detect the location of the pixel. Use Finder Tool and get the pixel. In the 'Control' tab you can get the coordinates, 'Mouse' tab you can get the color.

Feb 8, 2015#3

Autoit has an Information Window, you can use that to detect the location of the pixel. Use Finder Tool and get the pixel. In the 'Control' tab you can get the coordinates, 'Mouse' tab you can get the color.

I have seen that, but I don't think it takes into account the offset. I have tried to make a tool, but mine is very sad 🙁 I get the coords (assuming they are correct) and, sometimes, I get the color, but most of the time the color comes back as, 'FFFFFF'.

Try to hold back your laughter, but this is what I have so far:

#include <Misc.au3>
#include <WinAPI.au3>

Global $BSpos[2] ; Inside BlueStacks positions relative to the screen

$Title = "BlueStacks App Player for Windows (beta-1)" ; Window name
$Full = WinGetTitle ($Title) ; Get The Full Title..
$HWnD = WinGetHandle ($Full) ; Get The Handle
WinActivate ($HWnD)

Func getBSPos()
	$aPos = ControlGetPos($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]")
	$tPoint = DllStructCreate("int X;int Y")
	DllStructSetData($tPoint, "X", $aPos[0])
	DllStructSetData($tPoint, "Y", $aPos[1])
	_WinAPI_ClientToScreen(WinGetHandle(WinGetTitle($Title)), $tPoint)

	$BSpos[0] = DllStructGetData($tPoint, "X")
	$BSpos[1] = DllStructGetData($tPoint, "Y")
EndFunc   ;==>getBSPos

HotKeySet ("{F7}", "FindPos")
HotKeySet ("{F8}", "Terminate")

While 1
   Sleep (100)
WEnd

Func FindPos()
	getBSPos()
	Local $Pos[2]
	Local $iColour = 0
	While 1
		If _IsPressed("01") Then
			$Pos[0] = MouseGetPos()[0] - $BSpos[0]
			$Pos[1] = MouseGetPos()[1] - $BSpos[1]
			$iColour = Hex (PixelGetColor($Pos[0],$Pos[1]),6)
			ClipPut($Pos[0] & "," & $Pos[1] & "," & $iColour)
			Return $Pos
		EndIf
	WEnd
 EndFunc   ;==>FindPos

 Func Terminate()
   Exit
EndFunc   ;==>Terminate
Feb 8, 2015#6

I use ColorPic to get colors: http://www.iconico.com/colorpic/

AND

I use Greenshot to get coordinates: http://getgreenshot.org/

for coordinates i use this autoit script...iim not sure these are correct coordinates in game..

#AutoIt3Wrapper_UseX64=n

; Set the Escape hotkey to terminate the script.
HotKeySet("{ESC}", "_Terminate")

Example()

Func Example()
    ; Initialize a Local variable.
    Local $aMgp = 0

    ; Create an endless loop, 1 will always be 1 therefore True.
    While 1
        ; Assign a Local variable the coords of the cursor (array).
        $aMgp = MouseGetPos()

        ; Display a tooltip near the cursor with its coords.
        ToolTip("x: " & $aMgp[0] & ", y: " & $aMgp[1], $aMgp[0] + 10, $aMgp[1] + 10)

        ; Avoid high CPU usage.
        Sleep(50)
    WEnd
EndFunc   ;==>Example

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate
Feb 8, 2015#7

Try to use Control Viewer
http://www.autoitscript.com/forum/topic/126716-control-viewer-autoit-window-info-tool/

This seems to work quite well. Thank you for the link.

for coordinates i use this autoit script...iim not sure these are correct coordinates in game..

#AutoIt3Wrapper_UseX64=n
; Set the Escape hotkey to terminate the script.
HotKeySet("{ESC}", "_Terminate")
Example()
Func Example()
   ; Initialize a Local variable.
   Local $aMgp = 0
   ; Create an endless loop, 1 will always be 1 therefore True.
   While 1
       ; Assign a Local variable the coords of the cursor (array).
       $aMgp = MouseGetPos()
       ; Display a tooltip near the cursor with its coords.
       ToolTip("x: " & $aMgp[0] & ", y: " & $aMgp[1], $aMgp[0] + 10, $aMgp[1] + 10)
       ; Avoid high CPU usage.
       Sleep(50)
   WEnd
EndFunc   ;==>Example
Func _Terminate()
   Exit
EndFunc   ;==>_Terminate

@Henk500 - I think your coordinates will be off a bit if you don't take into account the window borders. That is what getBSPos() and FindPos() are doing.

Feb 8, 2015#8

did you check the
">>>> Control <<<<" section in the summary-tab of the autoit windows info tool?

Feb 8, 2015#9

did you check the
">>>> Control <<<<" section in the summary-tab of the autoit windows info tool?

No, I probably (incorrectly) assumed I knew what I was doing and, no doubt, missed that 🙂

Feb 8, 2015#10

Snarg wrote:

safar46 wrote:

Try to use Control Viewer
http://www.autoitscript.com/forum/topic/126716-control-viewer-autoit-window-info-tool/

This seems to work quite well. Thank you for the link.

Henk500 wrote:

for coordinates i use this autoit script...iim not sure these are correct coordinates in game..

#AutoIt3Wrapper_UseX64=n
; Set the Escape hotkey to terminate the script.
HotKeySet("{ESC}", "_Terminate")
Example()
Func Example()
   ; Initialize a Local variable.
   Local $aMgp = 0
   ; Create an endless loop, 1 will always be 1 therefore True.
   While 1
       ; Assign a Local variable the coords of the cursor (array).
       $aMgp = MouseGetPos()
       ; Display a tooltip near the cursor with its coords.
       ToolTip("x: " & $aMgp[0] & ", y: " & $aMgp[1], $aMgp[0] + 10, $aMgp[1] + 10)
       ; Avoid high CPU usage.
       Sleep(50)
   WEnd
EndFunc   ;==>Example
Func _Terminate()
   Exit
EndFunc   ;==>_Terminate

@Henk500 - I think your coordinates will be off a bit if you don't take into account the window borders. That is what getBSPos() and FindPos() are doing.

Yes i think it is off a bit..havent figured out the offset as i didnt needed it yet...
When i look at the getresource() function, i figured the mousecoords aren precise

Got something to add?

Log in to post a reply.

Join the conversation