IDoNotKnowIt Posted September 5, 2007 Share Posted September 5, 2007 (edited) I am running a PixelSearch() with MouseMove() and what I noticed is that PixelSearch( 50, 50 , 755, 1000, 0xFF4000, 2 ) makes the mouse move at the same speed ( 18s ) as PixelSearch ( 750, 995, 755, 1000, 0xFF4100, 2 ). Is this some mistake of mine?Here is my code$X = 100, $Y = 150 $Y1 = 750 Do While @error = 1 And $Y <= $Y1 MouseMove( $X, $Y , 1 ) $Y = $Y + 1 PixelSearch ( 750, 995, 755, 1000, 0xFF4100, 2 ) WEnd For $i = 0 to 1 $Y1 = $Y1 - 20 Until @error <> 1 Edited September 5, 2007 by IDoNotKnowIt Link to comment Share on other sites More sharing options...
Phaethon Posted September 5, 2007 Share Posted September 5, 2007 Well the last param you filled in is "2" which defines the speed of the movement... Makes sense it moves the same speed lol.. Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
IDoNotKnowIt Posted September 5, 2007 Author Share Posted September 5, 2007 (edited) Well the last param you filled in is "2" which defines the speed of the movement...Makes sense it moves the same speed lol..I think, that the last "2" in my PixelSearch() is the shade variation.P.S. the speed to move from y = 100 to y = 750 is 18 s. Edited September 5, 2007 by IDoNotKnowIt Link to comment Share on other sites More sharing options...
herewasplato Posted September 5, 2007 Share Posted September 5, 2007 ...and what I noticed is that .... makes the mouse move at the same speed ( 18s ) as ...It is not the PixelSearch that is determining the speed of that loop, it is the MouseMove line:MouseMove(x, y , speed)-MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Phaethon Posted September 5, 2007 Share Posted September 5, 2007 (edited) Doh! Edit: Got beaten to it... Edited September 5, 2007 by Phaethon Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
IDoNotKnowIt Posted September 5, 2007 Author Share Posted September 5, 2007 It is not the PixelSearch that is determining the speed of that loop, it is the MouseMove line:MouseMove(x, y , speed)-MSP-I do know that, but the interesting part is that when I use the same loop without PixelSearch() it completes in 8 s, which is 10 s faster. This is what bewilders me. Link to comment Share on other sites More sharing options...
Phaethon Posted September 5, 2007 Share Posted September 5, 2007 (edited) It does take quite a bit of time to search for pixels on the screen. That is one of the reasons they allow for user input as to a specific rectangle to search for the pixels in. If at all possible, make the rectangle you are searching in smaller, it will make it run faster etc... Edited September 5, 2007 by Phaethon Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
herewasplato Posted September 5, 2007 Share Posted September 5, 2007 (edited) Never mind - as soon as I posted that I figured I was wrong*, I should have deleted it until I could code a test. $start1 = TimerInit() PixelSearch(750, 995, 755, 1000, 0xFF4100, 2) MsgBox(0,"",TimerDiff($start1)) $start2 = TimerInit() PixelSearch(50, 50, 755, 1000, 0xFF4100, 2) MsgBox(0,"",TimerDiff($start2)) MouseMove(0,0,0) $start3 = TimerInit() MouseMove(0,1,1) MsgBox(0,"",TimerDiff($start3)) Could you post some code that runs? What you have in your OP is missing a "Next" and maybe a "Dim" line. Also, what is the code supposed to do? Edit: *The large pixelsearch should take longer than moving the mouse 1 pixel. The small pixelsearch should be faster than the mouse move with a speed setting of 1. Edited September 5, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
IDoNotKnowIt Posted September 5, 2007 Author Share Posted September 5, 2007 Actually this is the whole code. It should move the mouse until a color is found. It is running, but I forgot to write the "Next" in my first post. P.S. It is just a part of a project. Link to comment Share on other sites More sharing options...
IDoNotKnowIt Posted September 5, 2007 Author Share Posted September 5, 2007 I apologize to all of you. I have actually tested the smaller PixelSearch() in the second loop, so I got the same speed at the first loop, which was unchanged at all of my test. Link to comment Share on other sites More sharing options...
herewasplato Posted September 5, 2007 Share Posted September 5, 2007 ...It is running, but I forgot to write the "Next" in my first post....and forgot "Global" since you cannot just use "$X = 100, $Y = 150" My point is not to pick at typos or minor ommisions, it is just good practice to run the code that you post - then copy/paste it from SciTE to the forum. There is not much of a relationship between where the mouse is moving and where the PixelSearch is taking place... in other words, in this code:While @error = 1 And $X <= $X1 MouseMove( $X, $Y , 1 ) $X = $X + 1 $red1 = PixelSearch ( 50, 50 , 755, 1000, 0xFF4100, 2 ) WEnd you move the mouse one pixel, then search the whole rectangle, you move the mouse one pixel, then search the same rectangle, you move the mouse one pixel, then search the whole rectangle, ..... You might want to look into PixelGetColor. -MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted September 5, 2007 Share Posted September 5, 2007 ...Actually this is the whole code...You might want to run what you posted or at least do a syntax check :-)While @error = 1 $X <= $X1is missing an "And":-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
IDoNotKnowIt Posted September 5, 2007 Author Share Posted September 5, 2007 (edited) Thanks for the review. The PixelGetColor() looks like a better solution. Edited September 5, 2007 by IDoNotKnowIt Link to comment Share on other sites More sharing options...
herewasplato Posted September 5, 2007 Share Posted September 5, 2007 (edited) Thanks for the review. The PixelGetColor() looks like a better solution.You are welcome. Here is a sample for you to try. For $x = 0 To 150 Step 10 For $y = 0 To 300 Step 10 MouseMove($x, $y, 1) If PixelGetColor($x, $y) = 1394780 Then ExitLoop 2 Next Next Change the MouseMove speed to 0 and see how it runs... Edited September 5, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
IDoNotKnowIt Posted September 5, 2007 Author Share Posted September 5, 2007 You are welcome. Here is a sample for you to try. For $x = 0 To 150 Step 10 For $y = 0 To 300 Step 10 MouseMove($x, $y, 1) If PixelGetColor($x, $y) = 1394780 Then ExitLoop 2 Next Next Change the MouseMove speed to 0 and see how it runs... Looks fine, and works fine. The thing is that the specific color will not apear if the mouse is not on cordinates x, y. Moreover it will not appear on the cordinates of the mouse x, y, but on x1, y1. Looks like I will need some loop for PixelGetColor() ( to search a 50x60 rectangle ), still MouseMove works fine even at the speed of "0." P.S. Thanks a lot (again). I will try to implement this code in my project. Link to comment Share on other sites More sharing options...
herewasplato Posted September 5, 2007 Share Posted September 5, 2007 ...The thing is that the specific color will not apear if the mouse is not on cordinates x, y. Moreover it will not appear on the cordinates of the mouse x, y, but on x1, y1. Looks like I will need some loop for PixelGetColor() ( to search a 50x60 rectangle ), still MouseMove works fine even at the speed of "0."...You are welcome. If you need to search an area around the mouse, then it is back to PixelSearch:For $x = 0 To 150 Step 10 For $y = 0 To 300 Step 10 MouseMove($x, $y, 1) If IsArray(PixelSearch($x - 25, $y - 30, $x + 25, $y + 30, 0xFFFED8, 2)) Then ExitLoop 2 Next Next...but a PixelSearch that is tied to the mouse position and searches a small area. You may want to tighten/loosen the "Step 10" portion of that sample code above... it was just there to speed up the demo. It all depends on how big your target area is - maybe you can make it bigger. The bigger the number, the faster the scan. -MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] 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