bookmark bar toggle via AutoHotKey
-
bpm2 last edited by
So here's a clunky, primitive macro that navigates the GUI to operate a control - the sort of thing we used to make buttons for, back when Opera had a built-in system for clunky macros. But now you have to get that separately - and AutoHotKey is there. Free, open source - and a serious language, which you can use quite casually, or use to build applications. Download from http://ahkscript.org . (There's been a revolution in AHK-land, and the zombie hordes now control AutoHotKey.com. Or something.)
One benefit of learning to use it - it sits on top of everything, and lets you automate procedures, add functions, or change your keyboard in any application, and in Windows too.
There's nothing clever here. The macro just opens the Settings page, puts "book" in the search field to make the page shrink, clicks a location which if all goes well holds the radio button that toggles the bar, and dismisses the page. Because the radio button is lower on the page when the bar is showing, two commands are used.
It's brittle - it jumps blindly to a specific location on the page, and won't work if you change page size. More sophisticated forms that find the position of the control, and will work regardless of resizing, are possible (any volunteers?). And you might have to adjust the delays which are put in to let Opera finish responding to one action before the next is launched; machine speed matters, and the delays I've used are just the shortest that haven't failed here.
You will need to set up a script and put a shortcut to it in your startup folder. It can include sections to work with other programs too. Here's the code for the toggle:
#IfWinActive ahk_class Chrome_WidgetWin_0 ; Opera 20 !b:: ; show bookmark bar send !p sleep 400 send book sleep 500 click 496,170 send ^w return !c:: ; clear bookmark bar send !p sleep 400 send book sleep 500 click 496,200 send ^w return
There's a utlity in AHK called Window Spy you use to determine the location to click.
If there's anyone to whom this seems worth investigating - and, after all, there used to be a little band of button-makers - well great! -
bpm2 last edited by
[mod edit: thanks for sharing
I moved your corrected code up into your original post] -
bpm2 last edited by
Here's a more competent form - a one-key toggle, which doesn't rely on screen position & works regardless of resizing.
#IfWinActive ahk_class Chrome_WidgetWin_0 ; Opera 20 !b:: ; bookmark bar toggle send !p sleep 1000 send book sleep 600 send {tab}{space}^w return
The 1-second delay, waiting for the settings page to load, isn't always enough; seems to take especially long when one is on this site, for some reason. But no harm is done if it fails.