How to automate clicking in a Chrome extension popup with a hotkey

google-chromekeyboard

I want to create a workflow on my Mac where I select text on a Chrome webpage and then press a hotkey combination to change the title of tab to be the selected text.

I generate lots of tabs that get identical titles and I want to tag them with something based on the contents to be able tell them apart. I use the Chrome extension Tabs Outliner that displays a tree diagram of my tabs with their titles. Once the tab structure is in Tabs Outliner, I can do various things like copy the tree of that window and paste it into Google docs as an archive of the tabs I created, my research, testing versions, whatever.

But all my various archiving flows depend on the tabs having meaningful titles. The website(s) are not doing that sufficiently for my purposes, so I want to manually tag them, in most cases as quickly and easily as possible. Select text and press a hotkey seems about as quick as I can get short of having the computer read my mind and track my eye movements. Maybe add the complexity of stopping to allow me to edit the pasted text and then pressing another hotkey to confirm and move on.

My idea is to have the hotkey initiate something like the following automatic flow.

  1. Cmd+C: Copy the selected text.
  2. Ctrl+Shift+A: Open the RenameTab Chrome extension.
  3. Cmd+V: Paste the copied text into the RenameTab text field in the dropdown.
  4. CLICK the "Lock Title (beta)" button in the RenameTab dropdown.
  5. Ctrl+Tab: Move to the next browser tab.

I can write a simple Service to send all the keystrokes. But don't know how to automate the Click that is required.

I want to be able to do this approximately 20-40 times a day, day after day, so I cannot presume that the Chrome window will be at the same screen location, on the same monitor, the same window size, or any of the other assumptions that basic click-automation scripts like Cliclick seem to require.

I can presume that the RenameTab dropdown will be at the same relative location to the Upper Right corner of the Chrome window (actually relative to the extension button which is mostly stable). The image here is on Windows, from the Chrome web store, but I'm working on a Mac.

Dropdown is positioned relative to the Upper Right corner of the browser.

I've found references to Selenium as possibly able to do that click, but the Selenium tutorials that I've found want to put me through weeks of becoming a Test Automation expert.

I presume that Selenium can do its thing in a way that defaults to the current browser window, current browser tab. But how do I tell Selenium where to click?

Can Selenium recognize that the browser frame, not the current web page, has displayed a dropdown window and can it find the button by name? All the stuff I've been able to understand about Selenium so far is that it seems to deal with the displayed web page, so maybe it cannot deal with being able to identify content that's generated by the browser frame itself.

Do I maybe need to forgo Selenium instead using more basic click automation tools and capture the current window size and then subtract the coordinates based on the Upper Right corner to get the click coordinates relative to the current window? Do I need to also deal with the current window position on the screen?

Sorry for dumping all the details, but I don't know how to ask the question more simply without running the risk of presuming what the solution is when I really don't know. So I'm trying to explain exactly what I want to do, in what context, and why. In researching this, over and over I find that the descriptions of various tools are enthusiastic descriptions of how the tool works in use cases that don't seem to overlap with mine, without ever explaining the underlying operating mechanism so that I can determine whether or not the tool is even possibly equipped to do the job.

Any experienced guidance would be appreciated. If you can tell me things like "Cliclick presumes this so you won't be able to …" or "Selenium can only deal with what it gets from … so you'll have to …" or point me to where the basic operating principles are outlined, I would be grateful.

Thanks.

Best Answer

I haven't found a free solution, but I've been able to solve my problem with the free-trial version of Keyboard Maestro.

KBM allows you to record key clicks and mouse motions, and with an option on the Recording process, you can include real-time time delays that can then be edited to speed up the process without it zipping along too fast for the apps and app switcher to keep up.

On thing about KBM that is very useful, as hinted at in my problem description, is that the mouse clicks are initially recorded relative to the upper right corner of the screen or the frontmost window, BUT, after recording, you can change what the zero-point is for the mouse coordinates. In my case, changing the mouse clicks to be relative to the upper right corner means that they should be pretty stable w.r.t. where the RenameTabs Chrome extension dropdown dialog appears.

I still don't know how to capture the current window size, which would be required for a totally free solution. One option I've thought of is to use another Chrome extension, Easy Window Resize, to ensure that that the window is always at a predefined size so that I can indeed use Cliclick relative to the upper left corner. That could be a free solution.

I probably won't go that way for my own purposes because, the other features of KBM make it look like a worthwhile investment for me.

DISCLAIMER: I am just a customer, currently using the free version of KBM and am not affiliated with the company in any way. I haven't even paid them anything yet.