hermherm Posted September 14, 2006 Share Posted September 14, 2006 (edited) Hi again So I got a problem with my pixelsearch functionI use it for a game, and in this game there appears a specific colorwithin 30 seconds but you never know exactly when it appears...it's randomlyso I use pixelsearch and a timer which lasts for 30 secondsbut after 10-15 seconds I got an exeption from pixelsearch (image below)sure.. I can catch the exception, no problem... but pixelsearch wouln't search again for the colorSo what can I do that he searches for the 30 seconds constantly without throwing exeptionswhile(!timerout ) // timerout get's true if 30 seconds passed { searchs =PixelSearch (s_left, s_top,s_right,s_bottom, 1, 0x8A99E3, 20); bool found= System.Convert.ToBoolean(searchs); if(found) { break; } autoit.Sleep(10); }and that is my pixesearch functionprivate int[] PixelSearch(int startX,int startY,int rangeX,int rangeY, int step,int color,int shade) { for(int x=startX;x<startX+rangeX;x+=step) { for(int y=startY;y<startY+rangeY;y+=step) { if(autoit.PixelGetColor(x,y)==color) // if(autoit.PixelGetColor(x,y)==color) return new int[]{x,y}; } } throw new ApplicationException("PixelSearch: Failed to find the color ("+color.ToString()+")"); }Would be very nice if someon could help me ty Edited September 14, 2006 by hermherm Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now