terrypin Posted February 27, 2015 Report Share Posted February 27, 2015 Can anyone suggest a reliable method to determine whether the left hand sidebar in Firefox (for bookmarks or history) is open or not please? My current method is based on pixel colour testing, which in turn is dependent on the number of tab rows i have open. I wrote it a few years ago in haste and it worked cheerfully for a long time. But it now fails, presumably following an FF version change or something else I hadn't anticipated, and it's time to develop a more elegant approach. --Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
acantor Posted March 1, 2015 Report Share Posted March 1, 2015 I don't think there is an elegant way for Macro Express to detect Fiirefox sidebars. Maybe with an external script? Quote Link to comment Share on other sites More sharing options...
terrypin Posted March 1, 2015 Author Report Share Posted March 1, 2015 Thanks Alan. Quote Link to comment Share on other sites More sharing options...
acantor Posted March 2, 2015 Report Share Posted March 2, 2015 There is an add-in for Firefox called "Old Bookmarks Sidebar" that might allow your old script to continue to work, at least a while longer! Quote Link to comment Share on other sites More sharing options...
terrypin Posted March 2, 2015 Author Report Share Posted March 2, 2015 Thanks Alan. Installed it and was initially puzzled that it made no difference at all to the appearance of the sidebar. Then I realised that I'd installed an add-on long time ago (after a truly radical change in the FF UI) called Classic Theme Restorer. Amongst scores of other things, that changed the sidebar back to its 'standard' form. So of course Old Bookmarks Sidebar was redundant. So there must have been some other change that's affected my pixel-based macro. I'm wondering whether an approach using Controls might be productive? Another might be to move the mouse cursor leftwards from an appropriate position and detect the RH edge of the sidebar (or not). Quote Link to comment Share on other sites More sharing options...
Samrae Posted March 2, 2015 Report Share Posted March 2, 2015 Terry, when I saw your post the other day I thought of using Window Controls and decided to try it. It did not work for me. Quote Link to comment Share on other sites More sharing options...
terrypin Posted March 2, 2015 Author Report Share Posted March 2, 2015 Thanks Samrae, that's saved me some wasted time! Quote Link to comment Share on other sites More sharing options...
acantor Posted March 3, 2015 Report Share Posted March 3, 2015 Macro Express does not detect Firefox controls particularly well, A pixel-sniffing script might be your best option, but it won't be elegant! Quote Link to comment Share on other sites More sharing options...
terrypin Posted March 10, 2015 Author Report Share Posted March 10, 2015 This macro uses the approach I suggested earlier and so far seems reliable. The starting horizontal position for the mouse cursor and the number of repetitons may need adjusting for other PCs. // Tests for Bookmarks or History sidebar Open or Closed.// Looks for the RH edge of a sidebar pane, between roughly its max of x=612 and min of x=200.// If it finds the edge by detecting a change of cursor to <--> while x is progressively reduced from its max of 612, sidebar is Open.// Otherwise, sidebar is Closed.Mouse Move: 612, 500 Relative to Current Window // Start point just beyond max possible rightmost position of sidebar.Repeat Start (Repeat 83 times) If Mouse Cursor: Size WE Variable Set String %tSidebar% to "Open" Repeat Exit Else Variable Set String %tSidebar% to "Closed" End If Mouse Move: -5, 0 Relative to Last PositionEnd RepeatVariable Save: Save Text Variables // Saves Sidebar status.Text Box Display: // Disable this command after testing. <COMMENT Value="Tests for Bookmarks or History sidebar Open or Closed."/> <COMMENT Value="Looks for the RH edge of a sidebar pane, between roughly its max of x=612 and min of x=200."/> <COMMENT Value="If it finds the edge by detecting a change of cursor to <--> while x is progressively reduced from its max of 612, sidebar is Open."/> <COMMENT Value="Otherwise, sidebar is Closed."/> <MOUSE MOVE Option="\x02" X="612" Y="500" _PROMPT="0x000A" _COMMENT="Start point just beyond max possible rightmost position of sidebar."/> <REPEAT START Start="1" Step="1" Count="83" Save="FALSE"/> <IF MOUSE CURSOR Cursor="6"/> <VARIABLE SET STRING Option="\x00" Destination="%tSidebar%" Value="Open" NoEmbeddedVars="FALSE"/> <REPEAT EXIT/> <ELSE/> <VARIABLE SET STRING Option="\x00" Destination="%tSidebar%" Value="Closed" NoEmbeddedVars="FALSE"/> <END IF/> <MOUSE MOVE Option="\x03" X="-5" Y="0" _PROMPT="0x000A"/> <END REPEAT/> <VARIABLE SAVE Option="\x01" _COMMENT="Saves Sidebar status."/> <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 tSidebar\\f1 = \\f0 %tSidebar%\r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _COMMENT="Disable this command after testing."/> Notes: 1. The mouse cursor changes to a double arrow, called 'Size W-E' in the drop-down list, and persists for 6 pixels horizontally. Choosing -5 for the looping Mouse Move was therefore theoretically OK and proved so in practice too, delivering the maximum speed. 2. Of course, the macro relies on there being no other region on the web page which could display a 'Size W-E' cursor. Time will tell. Meanwhile it's a far simpler approach than my previous pixel colour testing method. --Terry, East Grinstead, UK SidebarStatus.mex 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.