Sign in to follow this  
Followers 0
Johnshaddox

Massive lag with PixelGetColor() ;(DESPERATE)

9 posts in this topic

Having a huge problem with this line of code.

$CurrentPixelColor = Hex(PixelGetColor($HealthCoordsX[$target],$HealthCoordsY[$target]))

I set up a $LoopLag = TimerInit() at the beginning of the loop which this line contains. I put TimerDiff($LoopLag) at the bottom of the loop. I then call another function which takes $LoopLag as it's parameter. This function then outputs the contents of $LoopLag to my screen. Don't worry about all of that though. That's not the problem.

With the line commented out, the time ($LoopLag) it takes to process the whole loop (which is huge btw) in less than a millisecond, consistently. When I uncomment this line, my lag through the loop goes to between 40 and 1700 milliseconds. Yeah. 1.7 seconds. Something tells me this is not right.

At the moment this MASSIVE delay with this line is breaking my program... And this program is 100% dependent on reading the colors of these pixels. If you want a breakdown of what it does...

$CurrentPixelColor = Hex(PixelGetColor($HealthCoordsX[$target],$HealthCoordsY[$target]))

$HealthCoordsX[$target] and $HealthCoordsY[$target] are obviously both arrays with a total of 6 values each. I'm incrementing $target each time I pass through the loop to so it changes the coordinates of the pixel I'm looking at with each pass. The coordinates range between X=0, Y=0 and X=20, Y=100.

When I reach the limit on targets, I exit the loop.

The full loop is here... MIND YOU... these are just small sections of the code. You have all you need, though, if you want to help me try to figure this out...

while 1 = 1
    Sleep(100)
    While WinActive("World of Warcraft")
        if $Initialized = 0 Then
            $RunTime = Timerinit()
        EndIf
        $LoopLag = Timerinit()
        if $JoinedChannel = 0 Then
            sleep(3000)
            Send("{Enter}")
            sleep(100)
            Send("/join HBAI")
            sleep(100)
            Send("{Enter}")
            $JoinedChannel = 1
        EndIf
        if $HBAIENABLED = 0 Then
            HBAIGetPlayerClass()
            Sleep(1000)
        EndIf
        if ($HBAIENABLED = 1) Then
            While $Initialized = 0
                HBAIGetPlayerClass()
                GetPartyMembers()
                $Initialized = 1
            ;GetCombatStatus()
            WEnd
        EndIf
        CheckHealthBars()
        $ChatMessage = Timerdiff($LoopLag)
        HBAISend($ChatMessage)
    WEnd
WEnd

func CheckHealthBars()
    $Looping = 1
    While $Looping = 1
        $UrgencyRating = 0
        While $UrgencyRating < 5
            $target = 0
            While $target < 6
                if (Timerdiff($SleepTimer) >= $CastTime) OR (TimerDiff($SleepTimer = 0)) Then
                    $CurrentPixelColor = Hex(PixelGetColor($HealthCoordsX[$target],$HealthCoordsY[$target]))
;~                  if $CurrentPixelColor = $HealthBarColors[$UrgencyRating] Then
;~                      CastHeal($target, $UrgencyRating);Cast A heal
;~                      $target = 99;resets the variables to something absurd so it leaves the loop after we cast
;~                      $UrgencyRating = 99
;~                      $CastTime -= $LoopLag
;~                  EndIf
                EndIf
                $target += 1
            WEnd
        $UrgencyRating += 1                 
        WEnd
    $Looping = 0
    WEnd
EndFunc

I have a plate of $freshly_baked_cookies[$YourFavoriteFlavor] waiting for you when you finish fixing this. THANK YOU!

Share this post


Link to post
Share on other sites



I really need some help with this guys. Please...

Share this post


Link to post
Share on other sites

I really need some help with this guys. Please...

1. Do not bump your post within a 24 hour period of your last bump/original post/posts in general. It's disrespectful to others that are also seeking help and their posts drop to the bottom as a result of it.

2. Don't assume what we need to help you.

You've provided nothing here.

No OS.

No AutoIt Version.

It could be as simple as turning Aero theme off in Vista (assuming that's the OS).


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.

Share this post


Link to post
Share on other sites

1. Do not bump your post within a 24 hour period of your last bump/original post/posts in general. It's disrespectful to others that are also seeking help and their posts drop to the bottom as a result of it.

2. Don't assume what we need to help you.

You've provided nothing here.

No OS.

No AutoIt Version.

It could be as simple as turning Aero theme off in Vista (assuming that's the OS).

My apologies. I do not wish be a pest. (And I'm going to have to apologize again, because I have to post again... I could not figure out how to edit my original post to update it with this information)

Here's the information you asked for:

Running vista with aero on. (though it never looks at a single pixel while not in World of Warcraft...Infact... If WoW isn't active, it just sits there and waits.)

Auto It version: SciTE4AutoIt3 Version 1.76 Jun 12 2008 09:52:15

AND I've made a discovery... on accident, while sitting here eating a sandwich pondering my problem... I let the program run, it was spitting out the TimerDiff($LoopLag) every time it ran through the loop... Well... When I set my glass of coke down it bumped the mouse... TimerDiff($LoopLag) output of ~1500 ms went WAY down to ~50 ms. Now 50ms through the loop is quite acceptable. It got my attention so abruptly I nearly choked on my sandwich. It seems that PixelGetColor waits up to 1.5 seconds before returning a value if it does not detect mouse movement? I may not understand how this works correctly... This is FINE. Is there a way to disable this delay, though? Or am I going to have to find a way to factor in the TimerDiff($LoopLag)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

1. Why did you list what version of SciTe you are using, SmOke_N clearly asked for your AutoIt version.

2. TimerDiff() can't be what causes your problems since it's more or less instant, if there is any fault it's somewhere else in your code.

3. Did you turn off Aero to speed up your graphics functions?? (Also what SmOke_N said!)

PS: You should try READING when somebody with almost 13.000 posts give you advice muttley

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

1. Why did you list what version of SciTe you are using, SmOke_N clearly asked for your AutoIt version.

2. TimerDiff() can't be what causes your problems since it's more or less instant, if there is any fault it's somewhere else in your code.

3. Did you turn off Aero to speed up your graphics functions?? (Also what SmOke_N said!)

PS: You should try READING when somebody with almost 13.000 posts give you advice muttley

1: If there's another version that he needs, I don't know where to find it. I updated to my current version less than three days ago (release), and am still having the same problem. Does that help?

2. I wasn't even suggesting TimerDiff() might be causing the delay. You'd know that if you actually read any of my posts.

3. No, I didn't. don't know how. Really don't need to. You'd know that I don't need to if you actually read my code to see that this whole thing only functions if World of Warcraft is the active window. (Independent on Vista's Aero theme)

PS: You should try READING about the problem before attempting to solve it or offer criticism about it because people with almost 13k posts are apparently about quantity over quality, and would rather pull rank on every new guy that slips when he first walks in the door and play forum police all day rather than actually try to help people. And while you're sitting there slobbing his knob over the deal, I'm going to go back to my code, having already figured out what the problem is and how to solve it. If you'll get your daily jollies from it, feel free ban this account, this name, this email address, or hell, even this IP. I won't be coming back. I'll find no help here. Good day.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I know you don't think Aero has anything to do with this, but have you tried disabling it? It eats resources and slows video processing whether you are fullscreen in a game or not.

Also, I know that AdmiralAlkex was not extremely friendly toward you, but he is still trying to help. Please respect the people that try to help you on this forum. Insulting Smoke_N is disrespectful and will end in your banning. It is quality over quantity, as you say, and Smoke_N has contributed quite a bit of quality work to the community.

EDIT: I only read part of the rant at the end of your message. If you've given up on the community because you were aggravated by 2 of the tens of thousands of members, you are making a poor decision. Regardless, it is your loss; when you receive a constructive response 20 minutes after bumping your post, you have no right to complain.

Edited by Airwolf

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

1: If there's another version that he needs, I don't know where to find it. I updated to my current version less than three days ago (release), and am still having the same problem. Does that help?

SciTe and AutoIt are two completely different applications and if you can't understand that then why are you even at a programming forum?? It would only have taken you a couple of seconds to check your helpfile, @AutoItVersion macro or your AutoIt.exe but you refuse and continue throwing Scite's version at us. Do you really think that is smart?

2. I wasn't even suggesting TimerDiff() might be causing the delay. You'd know that if you actually read any of my posts.

Then why don't you tell me?? You can't expect the whole world to understand you after only 1 badly written post.

3. No, I didn't. don't know how. Really don't need to. You'd know that I don't need to if you actually read my code to see that this whole thing only functions if World of Warcraft is the active window. (Independent on Vista's Aero theme)

Maybe YOU should try reading before posting since you would have seen that running Pixel...() functions with Aero on increases the time by some hundreds of times. I can only assume you have an ignorant personality.

PS: You should try READING about the problem before attempting to solve it or offer criticism about it because people with almost 13k posts are apparently about quantity over quality, and would rather pull rank on every new guy that slips when he first walks in the door and play forum police all day rather than actually try to help people. And while you're sitting there slobbing his knob over the deal, I'm going to go back to my code, having already figured out what the problem is and how to solve it. If you'll get your daily jollies from it, feel free ban this account, this name, this email address, or hell, even this IP. I won't be coming back. I'll find no help here. Good day.

Do you really think a spammer could have become a MOD?? You are obviously under the standard this forum have and you think a spammer could have get to become Gods left hand?? You are funny muttley

(I am not really sure if it's left or right, feel free to correct my if I am wrong)

I know you don't think Aero has anything to do with this, but have you tried disabling it? It eats resources and slows video processing whether you are fullscreen in a game or not.

Read it and weep (or shout hooray if you are still using good ol' XP)

Also, I know that AdmiralAlkex was not extremely friendly toward you, but he is still trying to help. Please respect the people that try to help you on this forum. Insulting Smoke_N is disrespectful and will end in your banning. It is quality over quantity, as you say, and Smoke_N has contributed quite a bit of quality work to the community.

Look at the clock, it's freaking three in the morning!! :)

EDIT: I only read part of the rant at the end of your message. If you've given up on the community because you were aggravated by 2 of the tens of thousands of members, you are making a poor decision. Regardless, it is your loss; when you receive a constructive response 20 minutes after bumping your post, you have no right to complain.

I fully agree with that, I have been aggrevated more than double that amount of times (far more than 2, lol) and I am still here and I have never regret it. Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

1: If there's another version that he needs, I don't know where to find it. I updated to my current version less than three days ago (release), and am still having the same problem. Does that help?

2. I wasn't even suggesting TimerDiff() might be causing the delay. You'd know that if you actually read any of my posts.

3. No, I didn't. don't know how. Really don't need to. You'd know that I don't need to if you actually read my code to see that this whole thing only functions if World of Warcraft is the active window. (Independent on Vista's Aero theme)

I assumed you were using Vista, because they are the only ones that complain on Pixel* functions.

To learn more about your issue, and what you don't think it may or may not be (Aero)...

AutoIt, for PixelGetColor, uses the GetPixel API call.

Google:

GetPixel+Vista+Slow

http://www.google.com/search?q=GetPixel%2B...lient=firefox-a

Don't listen to a spammer like me, chances are MSDN itself will be the first link you see there, take it from the horses mouth.

PS: You should try READING about the problem before attempting to solve it or offer criticism about it because people with almost 13k posts are apparently about quantity over quality, and would rather pull rank on every new guy that slips when he first walks in the door and play forum police all day rather than actually try to help people. And while you're sitting there slobbing his knob over the deal, I'm going to go back to my code, having already figured out what the problem is and how to solve it. If you'll get your daily jollies from it, feel free ban this account, this name, this email address, or hell, even this IP. I won't be coming back. I'll find no help here. Good day.

I don't know how my post count, or your obvious lack of reading any of my support posts has to do with your original question.

Truth be known, policing dumb asses all day long does take its toll on ones patience.

Edited by SmOke_N

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.

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