jiut Posted June 7, 2011 Posted June 7, 2011 Hi there! I've just started using AutoIt and it's an incredible automation tool! I don't know why I haven't started using it earlier! Thank you developers! I've created a macro that detects if a white pixel is on the screen, and if it is, the mouse moves to that position. The function that I have so far is: func start () While 1 $variable = PixelSearch(277, 488, 786, 513, "0xFFFFFF", 0) If not @error Then MouseMove($variable[0], $variable[1], 0) EndIf WEnd EndFunc My question is, how can I detect if the pixel comes from above or below the specified area of the pixel search? I've thought of creating another search area and determining if the pixel moves from one to another, but how could I translate it into code? Any thoughts on this are very appreciated! Thank you! : D
FastFrench Posted June 8, 2011 Posted June 8, 2011 (edited) You should give more details on the context. Is there only one such white pixel at most in the area ? How are those pixels supposed to "move" ? The idea may be to compare the previous position with the new position, on each iteration of your loop. Edited June 8, 2011 by FastFrench
jiut Posted June 8, 2011 Author Posted June 8, 2011 There is not a specific amount of white pixels on the area. It can range from one to probably 10 or more at the same time. However, I'm only interested in the ones that enter the area from the top, and not from below. They may or may not come exactly straightly. They can move diagonally. The mouse should move to the ones that have the lowest Y position, or basically, move to the ones that enter the delimited are first. Preferably, the mouse should only move to the next pixel once the last pixel disappears from the designated area. How should I write it, so it compares the initial Y position of the pixel to the next (which should be lower)? Thanks once again
FastFrench Posted June 8, 2011 Posted June 8, 2011 You may write something very complicate to do that. But - and it may appear odd - but your code allready do the job in fact, as far as I can understand what you need. If you carrefully read the help for PïxelSearch, you'll see that, the way you use it, it will search from left to right, and from top to bottom. So it's the first white pixel starting from the first line at the top that will be found. Of course, in some occasions the result may niot be as expected (if down speed is not the same for all white pixels), but tracking movement of each white pixel would be much more complicate (and maybe not as reliable).
jiut Posted June 8, 2011 Author Posted June 8, 2011 (edited) Oh, of course! You're right! Since the area is delimited by the top left corner and then bottom right corner, it scans as I needed.But what if I need the opposite, the pixel coming from below?I've made pseudo-code and an image to explain the situation better:If (pixel 1 is moving up && is above Y1 && pixel 2 is below Y2) MoveMouse to Pixel 2 position else (MoveMouse to Pixel 1 position)Hopefully I could explain the situation in fully detail with the previous information.My problem is how to detect if the pixel is moving up.Is it possible to define two adjacent areas, and see if the pixel has moved from one to another (moving on the Y axis)?Thanks for all the help so far! Edited June 8, 2011 by jiut
BrewManNH Posted June 8, 2011 Posted June 8, 2011 If you change PixelSearch to search from bottom to top of your search area, it will detect anything that changes at the bottom before it finds it at the top. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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