camaro92 Posted February 5, 2009 Report Share Posted February 5, 2009 I have a macro that first uses the FIND feature in firefox to search for a word, it then ESC to the window itself (out of the FIND bar) then TAB's a couple times so it lands on a specific button. The problem I am having is trying to get the macro to get the COLOR under that button. Now normally a // Test the colour of the Find box Mouse Move: 100, 703 Relative to Current Window Get Pixel Color from Beneath the Mouse into %N[3]% // If colour is WHITE (16777215) then there is a hit. If Variable %N[3]% Equals "16777215" Text Box Display: WHITE Else Text Box Display: NOT WHITE Endif Is fine, except that the button is NOT always in the same area of the screen. However if the macro can simply jump to where ever the current tab went to, I could likely use that to find the color. I've tried Mouse Move: To the Text Cursor Position but it seems that the MOUSE itself does not move to the TABBED location so the Get Pixel Color from Beneath the Mouse into %N[3]% doesn't work.. Help! Quote Link to comment Share on other sites More sharing options...
terrypin Posted February 5, 2009 Report Share Posted February 5, 2009 I'd be happy to take a look at it but the solution usually depends heavily on the particular site. Can you give us a URL please? -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
acantor Posted February 5, 2009 Report Share Posted February 5, 2009 I've tried Mouse Move: To the Text Cursor Position but it seems that the MOUSE itself does not move to the TABBED location so the Get Pixel Color from Beneath the Mouse into %N[3]% doesn't work.. I don't think there is an elegant solution. I have tried to do what you are trying many times, without success. The problem seems to stem from Firefox. Firefox does not seem to be dealing with the normal text cursor when a link has focus, or even when a field has focus (and there really is a cursor there)! The upper left corner of the screen registers as the text cursor position, regardless of where it actually is. There is an add-in to Firefox that changes the colour of the find box if a search string is not found. I am not sure if that would help. But at least you could monitor the colour change at a fixed position on the screen. The best solutions I have come up with are pixel sniffing and mouse cursor checking. Pixel Sniffing: If I expect a colour change to occur somewhere along the vertical line x = 200... X = 200 Y = 100 // Start position // Repeat 300 times // Check up to 300 pixels along x = 200 Move Mouse to X, Y N = pixel color If N = Target Colour // Success - Perform an action and quit Macro Stop Else // Colour not found - Increment 1 pixel and try again Y = Y + 1 End if End Repeat Mouse Cursor Checking: If I expect a mouse pointer to change shape along the vertical line x = 200... X = 200 Y = 100 // Start position // Repeat 300 times // Check up to 300 pixels along x = 200 Move Mouse to X, Y If Mouse Cursor = Target Shape (e.g., internet pointer, horizontal split, whatever) // Success - Perform an action and quit Macro Stop Else // Cursor not found - Increment 1 pixel and try again Y = Y + 1 End if End Repeat More sophisticated versions of these scripts check pixels or mouse cursors along a spiral path, or check every pixel in an area of the screen, or in an extreme case, every pixel on the screen. But these are brute force methods that take time to run. (I have a macro that uses the spiral method; it checks a 2 cm by 2 cm patch of screen in three or four seconds. I use this method regularly. I also have written macros that check the entire screen, but these take too long to execute: on a 1280 x 1024 pixel screen, that's 1.3 million iterations.) Quote Link to comment Share on other sites More sharing options...
terrypin Posted February 5, 2009 Report Share Posted February 5, 2009 I've encountered another obstacle recently in using pixel and cursor checking routines in Firefox. This stems from using the multiple tab rows feature of the FF extension 'TabMix Plus'. As the number of rows changes, so does the relative position of various targets! And when I thought I'd taken care of that (with difficulty), I realised that sometimes the macro itself could add another site and hence occasionally another tab row. Is the extension you mentioned 'Highlight Focus'? That adds colour to some boxes reached by tabbing, but many other 'tabbed positions' aren't affected and still show only a faint marquee. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
acantor Posted February 6, 2009 Report Share Posted February 6, 2009 Is the extension you mentioned 'Highlight Focus'? That adds colour to some boxes reached by tabbing, but many other 'tabbed positions' aren't affected and still show only a faint marquee. It's "UI Tweaker." Quote Link to comment Share on other sites More sharing options...
camaro92 Posted February 6, 2009 Author Report Share Posted February 6, 2009 What about using the macro to grab the X and Y location of the cursor?? I don't see that as a feature in pro? Looks like just a " Mouse Move: X, Y Relative to Current Window" ? Can we not somehow grab the X and Y location and use THAT X and Y setting. Then move the mouse directly over to that X and Y location rather than using the feature to move the mouse to the text cursor which obviously doesn't work. If you click a link in firefox and go back it shows that link encased (selected) in a light outlined box. Is that location a way to determine the X and Y? Quote Link to comment Share on other sites More sharing options...
acantor Posted February 6, 2009 Report Share Posted February 6, 2009 What about using the macro to grab the X and Y location of the cursor?? I don't see that as a feature in pro? Looks like just a " Mouse Move: X, Y Relative to Current Window" ? Can we not somehow grab the X and Y location and use THAT X and Y setting. Then move the mouse directly over to that X and Y location rather than using the feature to move the mouse to the text cursor which obviously doesn't work. If you click a link in firefox and go back it shows that link encased (selected) in a light outlined box. Is that location a way to determine the X and Y? When scripting for Firefox, I know of no way to automatically move the mouse cursor (or the text cursor) to anywhere other than the upper-left corner of the viewport, other than the two convoluted (and not always reliable) methods I described in an earlier post: pixel sniffing and mouse pointer hunting. Given the popularity of Firefox, I propose a feature request: mouse movement commands that detect focused objects in Firefox. Quote Link to comment Share on other sites More sharing options...
terrypin Posted February 6, 2009 Report Share Posted February 6, 2009 When scripting for Firefox, I know of no way to automatically move the mouse cursor (or the text cursor) to anywhere other than the upper-left corner of the viewport, other than the two convoluted (and not always reliable) methods I described in an earlier post: pixel sniffing and mouse pointer hunting. Given the popularity of Firefox, I propose a feature request: mouse movement commands that detect focused objects in Firefox. I'll second that. Will you make the formal request? -- Terry, East Grinstead, UK 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.