Jump to content

Pixelsearch in While loop very slow


Voodo
 Share

Recommended Posts

Hey guys i wrote a small script. It should search for a certain colour and make sth. Not a big deal. The problem is that when you run the script its working pretty fast at first. But after a while its getting much slower and you even have to wait up to 20 sec until anything happens. Suddenly its fast again. I dont thing its because of my CPU cause the usage of the script is on 0%.

while 1
if $Active = 1 Then
     If IsArray (PixelSearch( $AWidth -5, $AHeigh -5, $AWidth +5, $AHeigh +5, 0x598D08,0,2)) = True Then
       Send("{enter}")
     ElseIf  IsArray (PixelSearch($OkWidth-5, $OkHeigh -5, $OkWidth +5, $OkHeigh +5, 0x598D08,0,2)) = True Then
      Send("{enter}")
     ElseIf IsArray (PixelSearch($BWidth -5, $BHeigh -5, $BWidth +5, $BHeigh +5, 0xE5E9E5,0,2)) = True Then
       send("{enter}")
       sleep(1000)
       Send("{esc}")
     Elseif IsArray(PixelSearch($VWidth -5, $VHeigh -5, $VWidth +5, $VHeigh +5, 0xE3E5E3,0,2)) = True Then
       Send("{TAB}")
    EndIf
EndIf
    Sleep(10)
WEnd

Do you now a solution to make the script more "stable"?

Thanks for your help!

Link to comment
Share on other sites

The reason it slows down is probably because it's getting further into the script and hitting a 2nd or 3rd elseif. The way you have it setup is it reiterates over the same set of pixels each time it hits an "ElseIf". So the first IF may take 10 seconds... if it hits the 1st ElseIf it may take 20 seconds, the 2nd ElseIf: 30 seconds etc. etc. etc.

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

  • Moderators

Hi, Voodo, welcome to the forum. Try something like this and see if it slows down.

While $Active = 1
Select
  Case IsArray (PixelSearch( $AWidth -5, $AHeigh -5, $AWidth +5, $AHeigh +5, 0x598D08,0,2)) = True
   Send("{ENTER}")
  Case IsArray (PixelSearch($OkWidth-5, $OkHeigh -5, $OkWidth +5, $OkHeigh +5, 0x598D08,0,2)) = True
   Send("{ENTER}")
  Case IsArray (PixelSearch($BWidth -5, $BHeigh -5, $BWidth +5, $BHeigh +5, 0xE5E9E5,0,2)) = True
   Send("{ENTER}")
   Sleep(1000)
   Send("{ESC}")
  Case IsArray(PixelSearch($VWidth -5, $VHeigh -5, $VWidth +5, $VHeigh +5, 0xE3E5E3,0,2)) = True
   Send("{TAB}")
EndSelect
WEnd

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Developers

Hi, Voodo, welcome to the forum. Try something like this and see if it slows down.

... and how is this different from the original posted code? Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I think i read somewhere that Aero and PixelSearch dont like each other very much.

Try the script with aero disabled.

The searchframes for the PixelSearch are very small so even multiple passes should be fast even if you have an older pc.

Also you could try to add a Sleep(10) within the loop

Hint: You dont need the "= True"

Edited by qsek
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Link to comment
Share on other sites

@qsek

You are talking about DWM, the engine powering Aero.

@Voodo

I'm gonna quote myself on this.

Try that. And maybe read the threads the quotes are from.
Link to comment
Share on other sites

... and how is this different from the original posted code?

I wonder the same thing. The case example works (logically) just like the IfElse example, as far as how the pixels are checked and in what order. But I dunno if CASE works faster than IfElse or if it's tomato tomato (toe-may-toe toe-ma-toe)

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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