I was wondering if there's a functionality in BetterTouchTool (or in general) where the screenshot tool would take a screenshot of the screen area based on its content automatically. It is hard to explain so I am attaching the screenshot. Here you can see what are I'd like it to take automatically for me after I click on that area. The UX would be similar to using Command+Shift+4 followed by the Space key and clicking on the window.
The aim here is to NOT use the crosshair to define the area manually, but have the procedure do it for you automatically. For example, the UX for this would be Command+Shift+4 followed by Option+Space to enter the selection tool.
If I understand you correctly, you want to take a screenshot of the currently hovered UI element, no mater which application you're in. The script below automatically obtains the coordinates, width and height, of the currently hovered UI element and then takes a screenshot of that rectangle.
//if you rename this, make sure to also rename it in the "function to call" field below.
async function someJavaScriptFunction() {
let hovered_element = await get_string_variable("hovered_element_details");
const regex =
/AXFrame:\s+"x=(\d+(?:\.\d+)?) y=(\d+(?:\.\d+)?) w=(\d+(?:\.\d+)?) h=(\d+(?:\.\d+)?)/m;
const match = regex.exec(hovered_element);
if (match) {
const [, x, y, w, h] = match;
let screenshot_command = `/usr/sbin/screencapture -c -R ${x},${y},${w},${h}`;
let cfg_screenshot = {
script: screenshot_command,
launchPath: "/bin/bash",
parameters: "-c",
};
let screenshot_result = await runShellScript(cfg_screenshot);
}
return screenshot_command
}
Is there a setting in this Action to capture a screenshot of the currently hovered UI element? I looked through that Action before writing the script and again just now and I can't find that setting.