iwaspwnd Posted January 5, 2010 Report Share Posted January 5, 2010 Hey I'm still figuring out this program but if any one could help script this simple task I would be very grateful. Basically I want it to do this 1. Get color of pixel 2. Set Pixel color as N1 3. If pixel color isn't N1 then 4. Move mouse to x,y 5. left click 6. move back over to the N1 pixel 7. left click again 8. repeat these steps Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 5, 2010 Report Share Posted January 5, 2010 You seem to have it figured out! Here's an outline: (Optional 1: Text Box Display "Position Mouse in Desired Location then hit keyboard Enter to proceed" ...when you hit Enter the Text Box Display disappears and the macro continues) Get Mouse Position into variables N5, N6 (to screen or window your choice) Get Pixel Color at N5, N6 into variable N1 (Optional 2: Put current partial window title into variable T1) Repeat Until ..... (your choice) (Optional 2: Activate partial window title T1 + short time delay) Get Pixel Color at N5, N6 into variable N2 If Variable N2 <> N1 Mouse Move N10,N11 (x,y to screen or window as above) Mouse Left Click Mouse Move N5, N6 (to screen or window as above) Mouse Left Click End If Time Delay (how often the pixel color is checked) Repeat End I'm sure a number of small time delays will be required depending on how quickly the page changes after the mouse is clicked. If the Time Delay is long, you could also put it at the start of the repeat loop so that there is not a long delay after the final Mouse Click. If you are monitoring a single pixel you cannot rely on the mouse staying exactly in place. That is why you save the mouse position as the first step and use the coordinates after that. I didn't debug the above. When to stop the repeat is too dependent on your application. You can stop the macro manually or add some logic to do it. Options: If you don't want to bother with the Text Box Display you will have to position the mouse before running the macro. If this is working unattended and particularly over long periods of time, you may need to add interlocks to ensure no other window is on top. I added the option of getting the current partial page title and activating before checking pixel color etc. This may not be needed if attended or short-term operation, and would be undesirable in high-speed checking (very short time delay). It may not work if the page title changes after the mouse click. That is why you use a partial title. Let's say it's Firefox, "Mozilla Firefox" is nearly always in every page title so you can ensure the browser is on top even though the full page title has changed. Depending on application you may also be able to use change of page title rather than mouse color. You may want to consider using the keyboard (Text Type) to do the necessaries at x, y (if it's a button) and more advanced, use Controls. Quote Link to comment Share on other sites More sharing options...
rberq Posted January 5, 2010 Report Share Posted January 5, 2010 You should be able to code it almost exactly as you have written it in English. Assuming that the pixel you want to check is at coordinates 123, 456; and that the other position you want to click is at 987,654; then this should do what you want. Note that when coding Get Pixel and the Mouse Move commands, you will have to specify whether the coordinates are relative to the whole screen, or relative to the window that has focus. Repeat Start (Repeat 2 times) Get Pixel: Window Coords: 123,456 into %N1% If Variable %N1% <> 123456789 Mouse Move Window 987, 654 Mouse Left Button Click Mouse Move Window 123, 456 Mouse Left Button Click End If Repeat End Here's the same macro in code format -- you should be able to copy and paste this right into the script editor, and experiment with it from there. <REP3:01:000001:000001:00002:0:01:><GETPX:1:W:000123:000456><IFVAR2:2:01:2:123456789><MMW2:987,654><LCLK><MMW2:123,456><LCLK><ENDIF><ENDREP> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.