Sign in to follow this  
Followers 0
BlackNovaHF

PixelGetColor Help

16 posts in this topic

Alright, Im working on something for a game that I play. My friend and I both made a program to do the same thing, and we kind of bounce ours back and forth. Both his and mine (When slightly edited for pixel location and color, but no other modification) work for him. I can't get either to work regularly. Like 1 out of 10 tries it will work properly, but most of the time it makes me leave game (done when a pixel is not equal to a certain color). I was wondering if anyone has had problems with pixel colors shifting at random? It's like everytime I check that pixel, its the color i expect, but when i set up my if statement that includes if pixel<>(color #) then bla bla bla....and it does the THEN when it shouldnt....

Also...does PixelGetColor get info from moniter or what CPU says is on moniter....

Not sure if it could be a problem with my moniter.....maybe a video setting...Im stumped

Share this post


Link to post
Share on other sites



1

Welcome to AutoIt Forums

2

Cant help you without viewing the script

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

1

Welcome to AutoIt Forums

2

Cant help you without viewing the script

8)

It's the guessing game that noObs love to play!! --- You post when your tired of chasing your tail!

[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

It's the guessing game that noObs love to play!! --- You post when your tired of chasing your tail!

You know... it seems to me that people like this think they have created something so great... and dont want anyone to "steal" their idea

when people like you and i help others with Fantastic scripts... write things these guys could never imagine...

and they were given this language and help for free

i don't get-it!!!!!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

This forum needs abbreviations like Scite - in your personal settings, you set "default" to be (example from Valuator's post):

1

Welcome to AutoIt Forums

2

Cant help you without viewing the script

8)

Then when you type in default and do some key combo, that standard response comes up. It would make things so much easier, since people always ask the same questions!

Share this post


Link to post
Share on other sites

maybe frost can make one for here like he did for SciTE

also.. we have a private "note-pad" in our control pannel.. it would be nice if we had a key-set for that..

also... since we understand hot keys.. we could make our own 'standard' response program that would send to this text-box for us

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Lol Well i was purposefully vauge because Diablo 2 and Battle.net frown on this kinda thing...

Lol not that i think you would steal my idea...its not even my idea....just trying to make one work cuz new version, no one really has anything like it out.....not widespread anyway

HotKeySet("{F10}", "Terminate")
HotKeySet("{F11}", "GetPOS")
HotKeySet("{F9}", "StartChicken")
HotKeySet("{Insert}", "Leave")

AutoItSetOption("MouseCoordMode",0)
AutoItSetOption("PixelCoordMode",0)

sleep(5000)
WinActivate("Diablo II")


$x=1
while $x=1
sleep(15000)
wend


Func Startchicken()
adlibenable("Chicken")
endfunc



Func Chicken()

$leave = PixelGetColor( 72 , 562 )
$pot = PixelGetColor( 72 , 536 )

Select
Case $leave = 6488064
case $leave = 1591568
case else
    sleep(100)
    if $leave <> 6488064 then
    send("{Esc}") 
    sleep(50) 
    mousemove( 373 , 262, 0) 
    sleep(50) 
    send("{Enter}") 
    adlibdisable()
    endif
EndSelect

select 
case $pot = 6488064
case $pot = 1591568
case else
    Send("{1}")
    Sleep(100)
EndSelect
EndFunc


Func GetPOS()
    $pos = MouseGetPos()
    sleep(1000)
    $mc = PixelGetColor( $pos[0] , $pos[1] )    
    send("{Enter}")
    sleep(100)
    send("x= " & $pos[0] & ", y= " & $pos[1] &", Color=" & $mc)
    sleep(100)
    send("{Enter}")
EndFunc

Func Leave()
    send("!{F4}")
    exit
EndFunc


Func Terminate()
    adlibdisable() 
EndFunc

Also, Stupid as it sounds....its such a specific problem that I didnt figure source code would do much good....its really only an issue with GetPixelColor..... the rest really matters none (as far as i know) *shrug*

Thanks for any help :o

--BlackNova

Share this post


Link to post
Share on other sites

Since it's Diablo II, you will want to know that PixelGetColor at the mouse coords is getting the colors of the mouse cursor (the glove). A fix would be to use mouse coords and just subtract 10 or so pixels from each dimension, so it checks the coords above and left of the cursor.

There's actually a surprising amount of game bot type scripts on here and all over the internet. One excellent botting script is called MMBot. Google it - it's not too tough to find.

Share this post


Link to post
Share on other sites

also... i think Larry worked on getting the color "Below" the mouse curser

i think its in the scripts and scrapts

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Larry's talented - I'm not surprised if he managed that.

Share this post


Link to post
Share on other sites

ACtaully if you look at my GetPOS Function theres a 1 sec delay after i hit the button....So i put the mouse on the health globe...hit F11... and i have a sec to move the mouse away before it reads for color :o

Thats not really the issue tho...the issue is that the pixel of the health globe acts like its changing color when my health is still full....even tho it visually looks the same, it kicks me outta the game like my life dropped.....90% of the time (other 10% it works perfectly, with the same code)....and the bot works on my friends comp...with modified pixel and color setting (different resolution i guess)....soooooo that means my color of that pixel just flucuates at random ? but that cant be because it DOES work on friends comp....i realize he checks another pixel but like 95% of the globe is a solid color...soooo Im confuzzled

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

1

you realize that pixelGetColor refers to this size '.' ( the dot )

2

you can use pixelsearch for a small area

3

you can use

If NOT pixelGetColor() = $my_Color then.. do something

just ideas

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

ACtaully if you look at my GetPOS Function theres a 1 sec delay after i hit the button....So i put the mouse on the health globe...hit F11... and i have a sec to move the mouse away before it reads for color :o

Thats not really the issue tho...the issue is that the pixel of the health globe acts like its changing color when my health is still full....even tho it visually looks the same, it kicks me outta the game like my life dropped.....90% of the time (other 10% it works perfectly, with the same code)....and the bot works on my friends comp...with modified pixel and color setting (different resolution i guess)....soooooo that means my color of that pixel just flucuates at random ? but that cant be because it DOES work on friends comp....i realize he checks another pixel but like 95% of the globe is a solid color...soooo Im confuzzled

Remember that Diablo II has weather effects. So those pixel fluctuations could be real.

Share this post


Link to post
Share on other sites

Yea...weather doesnt really leak over into bottom toolbar (I guess youd call it) though....

1

you realize that pixelGetColor refers to this size '.' ( the dot )

--Yes, of course I realize that, I'm not THAT ignorant.

2

you can use pixelsearch for a small area

--Well, I know there will be red in the area, or else I'm already dead and it is too late. This is why I want to search a specific pixel so that when it turns from red, I know the health has fallen below that and can act accordingly.....

3

you can use

If NOT pixelGetColor() = $my_Color then.. do something

--I've tried this ..... Also

if pixelgetcolor variable <> (color number) then Bla bla bla....

if pixelgetcolor variable = (color number) ...then nothing ELSE bla bla bla....

Its like nothing works.....yet it works on my friends comp

....This is the main issue really....I dont see why it would work for him and not me.

Its not an issue with the programming....

Its an issue with a particular command and perhaps video settings, I'm not sure

Just wondering if anyone has had similar problems

Share this post


Link to post
Share on other sites

New Code for this damn thing.....

I re-made attempting to use PixelSearch

I search the entire upper half of the health globe for the color of 90% of the globe.....

Ive been toying with the "shades" allowed..... even though 0 should work, since i gave the EXACT color and all i need is 1 damn pixel to be red and its happy (or should be)....but no...even when it is red....it STILL makes me leave game...MAKES NO SENSE!!! I'm tired of beating myself up over this one, going to bed....

Oh soo yea...its like with shades = 50 i NEVER leave game

with shades = 60, it ALWAYS leaves games....where the hell is the middle ground

how much is a "shade" anyway.....

Until tomorrow,

Goodnight and thanks for your efforts

HotKeySet("{F10}", "Terminate")
HotKeySet("{F11}", "GetPOS")
HotKeySet("{F9}", "StartChicken")
HotKeySet("{Insert}", "Leave")

AutoItSetOption("MouseCoordMode",0)
AutoItSetOption("PixelCoordMode",0)

sleep(5000)
WinActivate("Diablo II")


$x=1
$flag=0

while $x=1
sleep(15000)
wend


Func Startchicken()
    adlibenable("Chicken")
    $flag = 0   
endfunc



Func Chicken()

PixelSearch(35, 519, 111, 555, 6488064, 80, 10)

if @error=1 and $flag=0 then
    sleep(100)
    send("{Esc}") 
    sleep(50) 
    mousemove( 373 , 262, 0) 
    sleep(50) 
    send("{Enter}")
    $flag=1
    adlibdisable()
endif
EndFunc


Func GetPOS()
    $pos = MouseGetPos()
    sleep(1000)
    $mc = PixelGetColor( $pos[0] , $pos[1] )    
    send("{Enter}")
    sleep(100)
    send("x= " & $pos[0] & ", y= " & $pos[1] &", Color=" & $mc)
    sleep(100)
    send("{Enter}")
EndFunc

Func Leave()
    send("!{F4}")
    exit
EndFunc


Func Terminate()
    adlibdisable() 
EndFunc

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

1. PixelSearch(35, 519, 111, 555, 6488064, 80, 10) ; Try to use a hex here rather than Decimal

2. You have your Pixel and Mouse coord modes set to 0 for window, make sure you double check AutoInfo.exe to see if it is set to Window Coords and not Screen or Client. (Options >> Coord Mode >> Window)

3. Make sure you have your Color Mode in AutoInfo.exe set to RGB and not BGR. (Options >> Color Mode >> RGB)

4. If all the above fail try the code below (0xFF0000 is red, going 10 shades deep, and stepping back one in the For loop from 10 pixel search down to 1 pixel search, if it's found it exits, if not it continues the loop until the loop is done, and if it isn't an array, will return from where you called the function from originally. If $flag <> 0 then it doesn't even bother with the search (going off your function).

Func Chicken()
    If $flag <> 0 Then
        For $i = 10 To 1 Step - 1
            If Not WinActive('Diablo II') Then WinActivate('Diablo II')
            Local $PixSch = PixelSearch(35, 519, 111, 555, 0xFF0000, 10, $i)
            If @error Then 
                ContinueLoop
            Else
                ExitLoop
            EndIf
        Next
        If IsArray($PixSch) Then
            Sleep(100)
            Send("{Esc}")
            Sleep(50)
            MouseMove(373 , 262, 0)
            Sleep(50)
            Send("{Enter}")
            $flag = 1
            AdlibDisable()
        EndIf
    EndIf
EndFunc

Edit:

You may find that you will want to do away with the For loop if you find it taking an EXTRA long period of time, and just use 2 or 1 for the PixelSearch() step.

Edit2:

I don't know this game at all, but to be honest searching 36 pixels (Top_y = 519 / Bottom_y = 555) down for something that should be able to be done either on 1 pixel or 2 maybe, seems like a waiste (thinking of a straight line across here)

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

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