I've checked out this post from 2016 about clicking Chrome extension buttons, and I also followed the instruction and ran the script below in Script Editor.app
------------------------------------------------------------
# Get properties of buttons of toobar 1 in Chrome
------------------------------------------------------------
tell application "System Events"
tell application process "Google Chrome"
tell (first window whose subrole is "AXStandardWindow")
tell toolbar 1
properties of buttons
end tell
end tell
end tell
end tell
------------------------------------------------------------
However, running this script returns with this script error message:
"System Events got an error: Canβt get toolbar 1 of window 1 of application process "Google Chrome" whose subrole = "AXStandardWindow". Invalid index."
Specifically, the extension buttons I would like to be able to press are 1Password and Extensity.
Well, it looks like Google has altered Chrome's UI a bit...
Remove the extraneous button from the code and try this:
tell application "System Events"
tell application process "Google Chrome"
tell (first window whose subrole is "AXStandardWindow")
tell group 1
tell group "Extensions"
tell button "1Password"
perform action "AXPress"
end tell
tell button "Extensity"
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
end tell
It works on my macOS 10.12.6 system with Google Chrome 71.0.3578.20.
Run this in the Applescript Editor.app, and look in the result panel.
-Chris
tell application "System Events"
tell application process "Google Chrome"
tell (first window whose subrole is "AXStandardWindow")
tell group 1
tell group "Extensions"
name of buttons
end tell
end tell
end tell
end tell
end tell
It's a browser history cleaner (Click&Clean) that I like to have clear out every 30 minutes since I am constantly referencing different dictionaries while working and after too long my browser starts lagging.
Unfortunately that button's name changes everytime a new page opens. It consists of "Visited Pages: (current number of page visits since last clean) Click&Clean".
Is there a way to tell it to just look for the one that contains Click&Clean much like the manipulate a window feature in KM?
tell application "System Events"
tell application process "Google Chrome"
tell (first window whose subrole is "AXStandardWindow")
tell group 1
tell group "Extensions"
tell (first button whose name contains "Click&Clean")
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
end tell
This Extensity extension allows me to quickly search for extensions that I wish to activate or deactivate, but pressing the arrow keys on my clipboard doesn't allow me to select the first search result. I can only do so using trackpad or mouse.
See photo
Is there a script I can use to select the first search result?
Very unlikely. The popup list is created by a Chrome extension, and therefore is not accessible by normal JavaScript-in-Browser.
Google claims this is for security.
Your only hope is to use Move or Click Mouse action based on found image. Use a unique image in the Dropdown, and then move the mouse down a sufficient amount to click on the desired item in the list.
Also β since the Extensity UI is browser-created System Events can't see it to do UI-Scripting.
However β there are a couple of approaches available.
You can get the button position to index on and then use a Keyboard Maestro click action to click a fixed offset from that position.
tell application "System Events"
tell application process "Google Chrome"
tell (first window whose subrole is "AXStandardWindow")
tell group 1
tell group "Extensions"
tell button "Extensity"
set extensityButtonPosition to its position
end tell
end tell
end tell
end tell
end tell
end tell
tell application "Keyboard Maestro Engine"
setvariable "buttonX" to item 1 of extensityButtonPosition
setvariable "buttonY" to item 2 of extensityButtonPosition
end tell
Or you can index off the Extensity UI Window position once it's open.
tell application "System Events"
tell application process "Google Chrome"
set extensityWindowPosition to position of window 1
end tell
end tell
tell application "Keyboard Maestro Engine"
setvariable "buttonX" to item 1 of extensityWindowPosition
setvariable "buttonY" to item 2 of extensityWindowPosition
end tell
Or you can use the Click at Found Image action to find the Extensions separator bar:
And click at an offset from that.
I would probably use one of the first two, because they'll be just a little faster.
thank you for excellent scripts to trigger my chrome extensions, including the Evernote Web Clipper.
I was wondering, from a UI Browser point of view, what exactly is the Evernote Web Clipper 'Window' ?
Is it a window ?
Is it accessible via UI Browser: is a script to click in the title field or some important info field (for which evernote does not provide shortcuts, contrary to other fields such as notebook and tags) possible using UI Browser info ?
UI Browser, and AppleScript, can only see the macOS window elements.
They can NOT see the HTML elements you see on a web page.
So, in the case of a web browser, the whole web page is seen as a "AXScrollArea".
They can NOT see the Evernote Clipper window, which is a window inside of an HTML frame.
Furthermore, as I have said elsewhere, Chrome (and Safari I think) will NOT allow JavaScript injection to get or set the HTML elements within a HTML frame.
Bottom line: Unless the web browser extension provides keyboard shortcuts, or other API, the only way to access the fields in this type of window is by KM Found Image, and then click at offsets to that found image.
I'm trying to get the name of the Chrome extension button that's directly to the left of the Zoom Scheduler button. Any input would be appreciated and I'm grateful for all of the contributions you've made in these forums.
I ended up using someone's suggestion in a different post to download the Chrome extension 'Shortkeys' and used it to create keyboard shortcuts for the app extensions in my toolbar.