Sign in to follow this  
Followers 0
omglol

PixelGetColor question:

17 posts in this topic

Hey,

I'm making a small bot for this game, and i want it to use an HP pot as soon as the color of the HP bar changes, and an MP pot if MP bar color changes.

I want it to do this before it starts attacking/looting, so i don't get killed.

While WinExists("Tantra Launcher")
    
        While WinActive("Tantra Launcher")
            
            While PixelGetColor(112,648) ;Check if HP bar is halfway empty
                MouseClick("left",20,92) ;Click Slot one (HP Pot)
                Sleep(500)
            WEnd
    
            While PixelGetColor(111,664) ;Check MP bar
                MouseClick("left",20,140);Click Slot two (MP Pot)
                Sleep(500)
            WEnd
            
                    Send ("e");target mob
                    sleep(50)
                    MouseClick("left",20,173);skill         
                    sleep(3000)
WEnd
    
    sleep(100)
    
WEnd

The attacking / using skills works like a charm, but with the pixelgetcolor it only spams my HP pots, how do i get it to use pots ONLY when the HP bar changes from color?

same with MP bar.

Share this post


Link to post
Share on other sites



Because you are never telling it what color it should be looking for. Only that it should be looking in a certain area.

You will need some If...ElseIf...EndIf statements to help you. Also look into ExitLoop, ContinueLoop, and Do...Until loops. Let me know if you need further help.

Also you will need to know the color value that you are looking for on that exact pixel you are pointing to in the PixelGetColor() function. Preferably in Decimal as I think that is the default output of PixelGetColor()

I hope the above helps,

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Just like JSThePatriot said...

While WinExists("Tantra Launcher")
    
        While WinActive("Tantra Launcher")
            
            While PixelGetColor(112,648) = Enter a color;Check if HP bar is halfway empty
                MouseClick("left",20,92);Click Slot one (HP Pot)
                Sleep(500)
            WEnd
    
            While PixelGetColor(111,664) = Enter a color;Check MP bar
                MouseClick("left",20,140);Click Slot two (MP Pot)
                Sleep(500)
            WEnd
            
                    Send ("e");target mob
                    sleep(50)
                    MouseClick("left",20,173);skill     
                    sleep(3000)
WEnd
    
    sleep(100)
    
WEnd

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the help man, really appreciate it, but how can i check the decimals for the color?

in photoshop you've got the codes with letters like 191a64, that's not decimals right?

Also, where exactly should the decimals go, is it like PixelGetcolor("191a64",111,646)?

Thanks in advance, really appreciate the fast help here.

EDIT: so While PixelGetColor(112,648) = 191a64, but i want it to click when it's NOT that color :whistle:

Edited by omglol

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If AutoIt Window Info doesn't work, try making a script that sleeps for a few seconds(to give you time to open the game) then does a PixelGetColor, then writes it to a file or MsgBox for you to write down/copy and use in your script.

Edit: Just about forgot... No, 191a64 is not a decimal number. Decimals only contain 1234567890.

Edited by BPBNA

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i knew that it wasn't decimal, but i got it now, thanks for the help there, so would this work?

While PixelGetColor(111,646) = Not 6292738
                MouseClick("left",20,140)
                sleep(500)
            WEnd
                        
            While PixelgetColor(111,663) = Not 1645156
                MouseClick("left",20,90)
                sleep(500)
            WEndoÝ÷ ØcºËgyçl¶%É0éâ·l4äíç^r)ËZµç^v+_¢¸(¶ÚuÛ(ëaxv+v¢»aÆ®¶­s`bVÄvWD6öÆ÷"ÃcCbÒæ÷Bc##s3FVà Ö÷W6T6Æ6²gV÷C¶ÆVgBgV÷C²Ã#ÃC 6ÆVWS VæD`  bVÆvWD6öÆ÷"Ãcc2Òæ÷BcCSSbFVà Ö÷W6T6Æ6²gV÷C¶ÆVgBgV÷C²Ã#à 6ÆVWS VæD`
Edited by omglol

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I hope the below code helps. The value that you are getting from Photoshop is the Hex value. So I used a built in function to convert Decimal to Hex, and here is the code.

While WinExists("Tantra Launcher")
    While WinActive("Tantra Launcher")
        While Not(Hex(PixelGetColor(112,648), 6) = "191a64") ;Check if HP bar is halfway empty
            MouseClick("left",20,92);Click Slot one (HP Pot)
            Sleep(500)
        WEnd
        While Not(Hex(PixelGetColor(111,664), 6) = "Other value from photoshop here") ;Check MP bar
            MouseClick("left",20,140);Click Slot two (MP Pot)
            Sleep(500)
        WEnd
        Send ("e");target mob
        Sleep(50)
        MouseClick("left",20,173);skill        
        Sleep(3000)
    WEnd
    Sleep(100)
WEnd

Edit: Added Not()

You will need to fill in the second value or it wont work properly.

I hope this helps you further,

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

If 6292738 and 1645156 are the colors of your HP and MP bars then yes that should use the potions whenever it is a different color. One thing I would make sure of is that there are no loading screens or any other windows or popups that would cover those areas as it would spam the potion during that time and might cause some problems/lag.

Share this post


Link to post
Share on other sites

JS, Would this do the exact same thing?

While WinExists("Tantra Launcher")
    
        While WinActive("Tantra Launcher")
            
            While Not PixelGetColor(111,646) = 6292738
                MouseClick("left",20,90)
                sleep(500)
            WEnd
                        
            While Not PixelgetColor(111,663) = 1645156
                MouseClick("left",20,140)
                sleep(500)
            WEnd
            
                    Send ("e")
                    sleep(50)
                    MouseClick("left",20,173)       
                    sleep(3000)
.....

Share this post


Link to post
Share on other sites

JS, Would this do the exact same thing?

While WinExists("Tantra Launcher")
    
        While WinActive("Tantra Launcher")
            
            While Not PixelGetColor(111,646) = 6292738
                MouseClick("left",20,90)
                sleep(500)
            WEnd
                        
            While Not PixelgetColor(111,663) = 1645156
                MouseClick("left",20,140)
                sleep(500)
            WEnd
            
                    Send ("e")
                    sleep(50)
                    MouseClick("left",20,173)       
                    sleep(3000)
.....
Yes it should... I would use the ( and ) just to be sure the Not negates the statement as a whole and not just PixelGetColor().

Just a little issue from me is your spacing and capitolization is all messed up. In my post it is fixed.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Ok straightened the spacing and caps up

While WinExists("Tantra Launcher")
    While WinActive("Tantra Launcher")
        While Not PixelGetColor(165,646) = 6292738
            MouseClick("left",20,90)
            Sleep(500)
        WEnd
        While Not PixelgetColor(111,663) = 1645156
            MouseClick("left",20,140)
            Sleep(500)
        WEnd
        Send ("e")
        Sleep(50)
        MouseClick("left",20,173)
.....

But what do you mean with the using "And"?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

While (PixelgetColor(111,663) <> 1645156)

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Smoke would that line mean that if it get's any greater/smaller figure that it would go click on 1?

if so, i will try it out right now.

EDIT: works like a charm, thanks for all the help guys!

Edited by omglol

Share this post


Link to post
Share on other sites

Smoke, your line worked allmost for me.

Is it also possible to check in a region if pixels with pixelchecksum, and if that total region goes to what it wasn't before, then pot?

the HP bar color's pixel changes after every hit a little bit, so i heal every time i get hit once, that's why i'm asking if this is also possible...

the region where it needs to look is filled with different shades of the color, so is that possible aswell?

the pixelchecksum asks for a (left,top,right,bottom,step) but where do i put what coord? from top right > top left > bottom left > bottom right you have an X and a Y coord.

Thanks in advance.

Share this post


Link to post
Share on other sites

I have no idea what "pot" means in your mind, means something completely different in mine :whistle: .

$Value = PixelCheckSum()
While $Value = PixelCheckSum()
    ;do something
WEnd

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

lol sorry, pot is basically using a potion :whistle:

anyways, how is that line going to scan this little part of my screen for an image, then see if it's changed and then use the script?

i want like pixelchecksum to check a small area, and if that total area changed colors, then pot.

Share this post


Link to post
Share on other sites

Just use an If/Then if you don't understand.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0