Jump to content

Pixelgetcolor Error?


Recommended Posts

Ok, i'm making a simple auto-pot bot for a game because when i'm fighting i'm constantly mashing the health pot hotkey. It works fine except for one big issue. When i use pixelgetcolor on my health bar, it returns black. So, i had autoit take a 100 pixel box of colors from the top left of the game screen and write each hex value to a file. Then i made a simple PHP script to convert that into an actual image. This is what pixelgetcolor is returning:

http://gogeta.homeip.net/mkimg/test.jpg

Any ideas why this might happen?

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs

    AruaRose AutoPot Bot
        By Gogeta70


#ce

Global $Hwnd = WinGetHandle("RoseOnline")
Global $Run = FALSE
Global $Coords
Global $Color

HotKeySet("{F9}", "startstop")
HotKeySet("{F10}", "gethealth")


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=E:\Documents and Settings\Gogeta70\My Documents\AutoIt Projects\AruaRose AutoPot\mainForm.kxf
$Form1 = GUICreate("AruaRose AutoPot", 233, 35, 192, 124)
$Label1 = GUICtrlCreateLabel("Hotkey: F", 8, 8, 50, 17)
$hkey = GUICtrlCreateInput("1", 58, 5, 17, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$bExit = GUICtrlCreateButton("Exit", 80, 8, 145, 17, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $bExit
            Exit

    EndSwitch

    While($Run == True)

        $file = FileOpen("colors.txt", 2)

        For $a = 0 to 100
            For $b = 0 to 100

                $clr = PixelGetColor($a, $b, $Hwnd)
                FileWrite($file, hex($clr, 6) & " ")


            Next


        Next
        FileClose($file)
        Debg("Done")
        Exit


        $fButton = GUICtrlRead($hkey)
        $tCol = PixelGetColor($Coords[0]-4, $Coords[1]-4, $Hwnd)
        $tCol = hex($tCol, 6)

        ;MsgBox(0, "Debug", $tCol & ":" & $Color)
        Debg($tCol)
        Sleep(2000)
        If $tCol <> $Color Then

            ControlSend($Hwnd, "", "", "{ENTER} DoPot {ENTER}")

            If $fButton == 1 Then
                ControlSend($Hwnd, "", "", "{F1}");
            EndIf

            If $fButton == 2 Then
                ControlSend($Hwnd, "", "", "{F2}");
            EndIf

            If $fButton == 3 Then
                ControlSend($Hwnd, "", "", "{F3}");
            EndIf

            If $fButton == 4 Then
                ControlSend($Hwnd, "", "", "{F4}");
            EndIf

            If $fButton == 5 Then
                ControlSend($Hwnd, "", "", "{F5}");
            EndIf

            If $fButton == 6 Then
                ControlSend($Hwnd, "", "", "{F6}");
            EndIf

            If $fButton == 7 Then
                ControlSend($Hwnd, "", "", "{F7}");
            EndIf

            If $fButton == 8 Then
                ControlSend($Hwnd, "", "", "{F8}");
            EndIf

        EndIf


    WEnd


WEnd

Func startstop()

    $Run = Not $Run

EndFunc

Func gethealth()

    $Coords = MouseGetPos()
    $Color = PixelGetColor($Coords[0]-4, $Coords[1]-4, $Hwnd)
    $Color = hex($Color, 6)

EndFunc

Func Debg($col)

    ControlSend($Hwnd, "", "", "{ENTER}" & Hex($col, 6) & " - " & Hex($Color, 6) & "{ENTER}")

EndFunc
Link to comment
Share on other sites

I think the problem is the makers of the game dont want you cheating and having an unfair advantage to anyone else.

You should also take a look at this.

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

It's not an unfair advantage. Anyone else can download AutoIt and make a bot as well. Saying that the lack of knowledge is the unfair advantage doesn't work either, considering i learned the AutoIt language in about 30 minutes.

All other players have the same resources i do to do the exact same thing i'm trying to do, so don't feed me that bullshit.

Edited by Gogeta70
Link to comment
Share on other sites

Then you might like to read this.

https://www.roseonlinegame.com/account/agreement.html

Especially this section

YOU MAY NOT USE THE SERVICES TO:

A) Use of illegal automated programs, Scripts, and Computers. The use of any illegal automated program (Ex. 3 rd party bot) or system, devices, computers, or scripts on R.O.S.E Online is strictly prohibited and may result in criminal liability under the Computer Fraud and Abuse Act, Section 1030 of the United States Code. Violators will be prosecuted to the full extent of applicable law and may also liable for the punitive damage. Gravity may terminate and permanently disqualify any users who, in its sole discretion, determines as being in violation of these Terms of Service. All decisions made by Gravity are final.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

I encounterd alot of this behavior while creating screenreading tools on some maschine configurations.

I recommend for healthbar reading the proper memtable and checking for the places in the client of your game. If that is over your abilities, you need your application to work in window-mode or you need to hook into its DX-calls (which should be over your abilities then aswell).

If you still get the black-problem in windowed mode your maschine might use SLI or XFire which result in a 'flickering' while reading from videomem. In that case you could write your own checkpixel like i finaly did that gets your proper results. Or you just modify the existing one like this

Func checkpixel(Const $xpos, Const $ypos)
    $cptimer = TimerInit()
    Local $color1 = 0, $i = 0
    While $color1 = 0 And $i < 3
        $color1 = PixelGetColor($xpos, $ypos)
        If $color1 = 0 Then Sleep(1)
        $i += 1
    WEnd
;~  ConsoleWrite('Color = '&$color1& ' ,Trys = '&$i&@CRLF)
    Return $color1
EndFunc   ;==>checkpixel

This will kill your overall performance but from what i get just reading a bar or checking on a button this will do.

If you are about to get into 'real' bot-coding your problems will be far more advanced, so will your skill.

Link to comment
Share on other sites

I encounterd alot of this behavior while creating screenreading tools on some maschine configurations.

I recommend for healthbar reading the proper memtable and...

Thank you for your input. As far as i know, AutoIt cannot access the memory space of other programs. I'm also a PHP coder, but PHP cannot really do that either. The reason i turned to AutoIt is because i'm still learning C++ and can't do something like this with it yet.

I'm pretty sure it's not an SLI error considering i'm only using a single nVidia (nVidia GeForce FX 5500), and i don't use xfire.

Also, like i said, i took a small 100x100 pixel square from the top left corner of the screen and had autoit read every pixel, surely some of them would've returned something other than black. Regardless, i'll try your function anyway.

Thanks again.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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