Jump to content
Macro Express Forums

Testing for Sidebar in Firefox?


Recommended Posts

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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 Position
End Repeat
Variable 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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...