TypoDemon Posted August 8, 2006 Report Share Posted August 8, 2006 Hello, I've been trying to write a fairly basic macro in which it would move the mouse cursor over a specific pixel color, left-click, wait thirty seconds, and repeat. While most of this would be very simple to execute, i'm having problems finding out how to get the Move Mouse command to move over a specific pixel color. I've tried looking through the in-program help and searching through previous posts in the forums, but I couldn't find any previous posts asking this sort of question. If anyone could help me out with this, or direct me to a previous post or help file entry where it explains how to do something like this, i'd really appreciate it. Quote Link to comment Share on other sites More sharing options...
GregChi Posted August 10, 2006 Report Share Posted August 10, 2006 I guess in your case you will need to scan over an area of your screen to locate the specific color & then proceed. (hope this helps) This is a copy of a previous msg I sent (WHEN USING NEWSGROUPS!!!!) as regards tray icons: methods to determine & select screen colors. Some guy Kevin :-) suggested a method for locating an icon the TrayNotifyWnd: "I do not have a suggestion about how to reliably activate programs by clicking on the system tray because, as you point out, the icons are not in consistent locations. The only thing I can think of is to use the Get Pixel Color command to see if a specific icon is in a certain location. However, this would be cumbersome and you would have to check enough pixels to distinguish one icon from any number of other icons." Ya, cumbersome. But possible with a lot of patience ....... These are my test/samples I finally built: 1st one shows the colors at many locations on the tray. 2nd one actually auto-searches for the colors. ----------------------------------------------- 1.FIND the colors of the icons: // Ctrl-W is hot key // use Scroll lock & Pause/Break to cancel // Method to determine (2) EXACT colors at a toggling (or not) icon // { Enable 'repeat' & 'dec' below to step thru all combinations} // // EXAMPLE..... // To get MacroExpress icon (find a color pair for it's icon): // Turn OFF: options, preferences, appearance, 'system tray' 'show running icon' // // If MacroExpress icon is 2nd from the right, // at aprox left (992/990) N4 =16711680/ N5=8421376 // at aprox left (991) N4 =8421376/ N5=16711680 // [ 12632256 appears to be Win98 BACKGROUND!!!!! ] // // screen is set at 1024 x 768 // use mouse locator 1st to get location // Set N9 to lowest possible horizontal location of search (800?) //(disabled)Variable Set Integer %N9% to 800 Variable Set Integer %N9% to 970 // set N3 to 'upper' row (aprox 746-767) Variable Set Integer %N3% to 755 // set N2 to 'lower' row (aprox 746-767) Variable Set Integer %N2% to 760 // Set N1 to highest possible horizontal location of search (1024?) // or for 1 specific location, set N1 to the horizontal location of search // (a toggling icon, for example; don't allow decrement) //(disabled)Variable Set Integer %N1% to 1024 Variable Set Integer %N1% to 1010 // Enable below items [repeat & dec] to step/ 'loop' thru tray Repeat Until %N1% = %N9% Variable Modify Integer: Dec (%N1%) Mouse Move Screen %N1%, %N2% Get Pixel: Under Mouse into %N4% Mouse Move Screen %N1%, %N3% Get Pixel: Under Mouse into %N5% // move mouse out of the way to observe w/o pop-up msg Mouse Move Position 0, 8 Text Box Display: variables Text Box Close: Repeat End Sound Wave File: Utopia Exclamation.wav Text Box Display: Done.... CODE <REM2: Ctrl-W is hot key><REM2: use Scroll lock & Pause/Break to cancel><REM2:Method to determine (2) EXACT colors at a toggling (or not) icon><REM2: { Enable 'repeat' & 'dec' below to step thru all combinations}><REM2: ><REM2:EXAMPLE.....><REM2: To get MacroExpress icon (find a color pair for it's icon):><REM2:Turn OFF: options, preferences, appearance, 'system tray' 'show running icon'><REM2: ><REM2: If MacroExpress icon is 2nd from the right, ><REM2: at aprox left (992/990) N4 =16711680/ N5=8421376><REM2: at aprox left (991) N4 =8421376/ N5=16711680><REM2: [ 12632256 appears to be Win98 BACKGROUND!!!!! ]><REM2: ><REM2: screen is set at 1024 x 768><REM2: use mouse locator 1st to get location><REM2:Set N9 to lowest possible horizontal location of search (800?)><DIS:<IVAR2:09:01:800><IVAR2:09:01:970><REM2:set N3 to 'upper' row (aprox 746-767)><IVAR2:03:01:755><REM2:set N2 to 'lower' row (aprox 746-767)><IVAR2:02:01:760><REM2:Set N1 to highest possible horizontal location of search (1024?)><REM2: or for 1 specific location, set N1 to the horizontal location of search ><REM2: (a toggling icon, for example; don't allow decrement)><DIS:<IVAR2:01:01:1024><IVAR2:01:01:1010><REM2:Enable below items [repeat & dec] to step/ 'loop' thru tray><REP3:08:000001:000002:0001:1:01:N9><NMVAR:09:01:0:0000001:0:0000000><MMS2:1N,2N><GETPXM:4><MMS2:1N,3N><GETPXM:5><REM2:move mouse out of the way to observe w/o pop-up msg><MMP2:0,8><TBOX4:T:1:000060000428000293000218:001:variablesCOLUMN n1= %N1% ROW, lower n2= %N2% color, lower n4= %N4% ROW, upper n3= %N3% color, upper n5= %N5% Select the combination you want to find: <Spc> to step thru (write them down on a REAL notepad...)><TBCLOSE:><ENDREP><WAV2:C:\WINDOWS\MEDIA\Utopia Exclamation.wav><TBOX4:T:1:000371000455000278000200:001:Done....COLUMN n1= %N1% ROW, lower n2= %N2% color, lower n4= %N4% ROW, upper n3= %N3% color, upper n5= %N5% > ----------------------------------------------------------------- 2. GET the colors: // Sample__GET MacEx Variable Icon inTrayNotifyWnd // Ctrl-Z // Method to find an icon that may display various pairs of // colors in the TrayNotifyWnd // can also find just 1..... // Also example of 'nested repeats' & early exits If Not Program Name "MACEXP.EXE" running Macro Stop End If //(disabled) Macro Playback Speed: 7 Times Slower than Normal //(disabled) Mouse Speed: 5 Milliseconds // set outer repeat loop size...(If missed 1st time thru, do again) Variable Set Integer %N10% to 10 Repeat Until %N10% = 0 // set upper row Variable Set Integer %N3% to 755 // set lower row Variable Set Integer %N2% to 760 // set left column limit (final set to 850) Variable Set Integer %N9% to 970 // set start/right column (final set to 1024) Variable Set Integer %N1% to 1024 // set primary repeat loop limit Repeat Until %N1% = %N9% // decrement counter N1 (move left) Variable Modify Integer: Dec (%N1%) // move mouse to lower position Mouse Move Screen %N1%, %N2% // get pixel in lower location N2 to N4 Get Pixel: Under Mouse into %N4% // move mouse to upper position Mouse Move Screen %N1%, %N3% // get pixel in upper location N3 to N5 Get Pixel: Under Mouse into %N5% // Show what we have HERE (disable text box for speed) Text Box Display: variables // TextBoxClose Absolutely needed to prevent multiple OPEN windows!!!!!! Text Box Close: variables // check for possible sets // start of set 1 If Variable %N4% = 8421376 AND If Variable %N5% = 16711680 // if found, set flag for found search Variable Set Integer %N10% to 11 Sound Beep // & exit out of inner loop Repeat Exit End If // end of set 1 If Variable %N4% = 16711680 AND If Variable %N5% = 255 Sound Beep Variable Set Integer %N10% to 11 Repeat Exit End If // etc If Variable %N4% = 16711680 AND If Variable %N5% = 8421376 Sound Beep Variable Set Integer %N10% to 11 Repeat Exit End If // // inner loop exit Repeat End // is flag set for found ? If Variable %N10% = 11 // Yes: jump past next repeat end Repeat Exit End If // N1 must = N9 // wasn't found; decrement & run thru scan again Variable Modify Integer: Dec (%N10%) //(disabled) Text Box Display: vars //(disabled) Text Box Close: vars // outer loop exit Repeat End // is flag set for found ? If Variable %N10% = 11 // yes: Do your operations on the item Sound Wave File: Musica Default.wav Mouse Move Position 0, 8 Text Box Display: Got it !!! //(disabled) Mouse Right Button Click //(disabled) Delay 1 Seconds //(disabled) Mouse Left Button Click //(disabled) Wait For Window Title: "close application - SNET internet caller ID" //(disabled) Text Type: <TAB><ENTER> Macro Stop End If // search failed find Text Box Display: Couldn't find those combinations CODE <REM2:Sample__GET MacEx Variable Icon inTrayNotifyWnd><REM2:Ctrl-Z><REM2:Method to find an icon that may display various pairs of><REM2: colors in the TrayNotifyWnd><REM2: can also find just 1.....><REM2:><REM2:Also example of 'nested repeats' & early exits><REM2:><IFOTH:14:1:MACEXP.EXE><MSTOP><ENDIF><DIS:<SPEED:00007><DIS:<SPMSE:00005><REM2:set outer repeat loop size...(If missed 1st time thru, do again)><IVAR2:10:01:10><REP3:08:000001:000002:0010:0:01:0><REM2:><REM2:set upper row><IVAR2:03:01:755><REM2:set lower row><IVAR2:02:01:760><REM2:set left column limit (final set to 850)><IVAR2:09:01:970><REM2:set start/right column (final set to 1024)><IVAR2:01:01:1024><REM2:set primary repeat loop limit><REP3:08:000001:000002:0001:1:01:N9><REM2:decrement counter N1 (move left)><NMVAR:09:01:0:0000001:0:0000000><REM2:move mouse to lower position><MMS2:1N,2N><REM2:get pixel in lower location N2 to N4><GETPXM:4><REM2:move mouse to upper position><MMS2:1N,3N><REM2:get pixel in upper location N3 to N5><GETPXM:5><REM2:Show what we have HERE (disable text box for speed)><TBOX4:F:3:000593000215000278000200:001:variablesn1 %N1% n10 %N10% n2 %N2% n3 %N3% n4 %N4% n5 %N5% ><REM2:TextBoxClose Absolutely needed to prevent multiple OPEN windows!!!!!!><TBCLOSE:variables><REM2:><REM2:check for possible sets><REM2: start of set 1><IFVAR2:2:04:1:8421376><AND><IFVAR2:2:05:1:16711680><REM2: if found, set flag for found search><IVAR2:10:01:11><REM2:><BEEP><REM2: & exit out of inner loop><EXITREP><ENDIF><REM2: end of set 1><REM2:><IFVAR2:2:04:1:16711680><AND><IFVAR2:2:05:1:255><BEEP><IVAR2:10:01:11><EXITREP><ENDIF><REM2: etc><IFVAR2:2:04:1:16711680><AND><IFVAR2:2:05:1:8421376><BEEP><IVAR2:10:01:11><EXITREP><ENDIF><REM2: ><REM2:inner loop exit><ENDREP><REM2:is flag set for found ?><IFVAR2:2:10:1:11><REM2:Yes: jump past next repeat end><EXITREP><ENDIF><REM2:N1 must = N9><REM2:wasn't found; decrement & run thru scan again><NMVAR:09:10:0:0000001:0:0000000><DIS:<TBOX4:T:2:000087000448000278000200:005:varsn1 %N1% n10 %N10% n2 %N2% n3 %N3% n4 %N4% n5 %N5% ><DIS:<TBCLOSE:vars><REM2:outer loop exit><ENDREP><REM2:is flag set for found ?><IFVAR2:2:10:1:11><REM2: yes: Do your operations on the item><WAV2:C:\WINDOWS\MEDIA\Musica Default.wav><MMP2:0,8><TBOX4:T:4:000590000220000278000200:005:Got it !!!n1 %N1% n10 %N10% n2 %N2% n3 %N3% n4 %N4% n5 %N5% ><DIS:<RCLK><DIS:<IDELAY:1><DIS:<LCLK><DIS:<WAITWIN2:000000:000010:close application - SNET internet caller ID><DIS:<TEXTTYPE:<TAB><ENTER>><MSTOP><ENDIF><REM2:search failed find ><TBOX4:T:1:000708000271000278000200:035:Couldn't find those combinationsn1 %N1% n10 %N10% n2 %N2% n3 %N3% n4 %N4% n5 %N5% > ---------------------------------------------------- Your color combinations WILL vary..... rsvp the ""newsgroup"" please I use these to 'kill' various programs that don't want to quit. (ZA free is a GREAT example) (do you really, really want me to terminate?????) (answer Yes or NO then press enter) Quote Link to comment Share on other sites More sharing options...
paul Posted August 10, 2006 Report Share Posted August 10, 2006 What's wrong with the "Move Mouse to Tray Icon" command? Doesn't this achieve, more reliably, what your code sets out to do? Quote Link to comment Share on other sites More sharing options...
GregChi Posted August 11, 2006 Report Share Posted August 11, 2006 Only that this is a generic/demo way to locate a color also outside the Tray. 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.