Does anyone have any ideas if there's a way to determine if the input/focus is on the address bar rather than other input dialog in a browser window?
For context, I would like to create some text expanding snippets that would generate URLs. I would like these to be triggered only when used inside the address bar.
There is no trigger for placing the cursor in the Browser's address bar.
But you might be able to detect it using UI scripting, or comparing the URL you get from copying the address with the %FrontBrowserURL%.
My approach would be to simply give the text expansion trigger a unique prefix that you only use when in the address bar. Use whatever is intuitive to you, but I would use a prefix something like ";ba.", for "Browser Address".
I believe all the big-name browsers—Safari, Chrome, and Firefox—and maybe the lesser-used browsers as well, use Command-L to invoke the Open Location command. In Safari, for example, this is also available by selecting File > Open Location…
This command highlights the browser address field. You could configure your macro(s) to first Simulate the Command-L keystroke (or select the appropriate menu item) before performing the text expansion.
Hi alpo, were you able to figure this out? I'm trying to do something similar, but I can't figure out how to do "if focus is on address bar", then expand the snippet.