Google chrome two windows, pushing link from one to another with applescript, hard or easy?

There's two windows, one on left, with lots of links, on right click there is not much in context menu, but you can open as links.


on right is another chrome window.


I'm trying to get an applescript that I can enter a hotkey (it doesn't matter, i'll reassign it to a trackpad gesture later) of my choosing, and when I hover over left window link and press hotkey it will send it to right window new tab.


It seems easy, but maybe it's not, i don't know applescript but I want to learn it's kind of important for me learning applescript or any scripting to have this filtering system (along with some notes apps) to organize lots of information, any help appreciated.

MacBook

Posted on Nov 16, 2020 7:58 AM

Reply

Similar questions

10 replies

Nov 16, 2020 9:02 AM in response to GGarrett2

It shouldn't be too difficult in KM: the main problem will be bringing the other window to the front. This Applescript works in Numbers, I don't know if it wil work in Chrome:


tell application "System Events"

tell process "Chrome"

perform action "AXRaise" of window 2

end tell

end tell


You would use that as an 'Execute' step.


In fact there are some options for bringing windows to the front in KM (Under 'Interface Control'). However I've looked for a method of copying the link URL without much success. You can use KM to control-click at the current mouse position, which will open the menu, so you'd need to drag the mouse to the 'Copy link' item and release it. You'll have to experiment on that. After that it's probably pretty straightforward.

Nov 16, 2020 8:31 AM in response to Roger Wilmut1

Thanks for reply, I also have km and btt, but without applescript their functionality is limited so that's why I'm trying to learn.


I use command click shortcut in btt to open new tabs nicely in current window, but not send to another window.


"You can click with command down to open in a new tab or window depending on how the browser is set"


Can I set it to do this in new window, that would be easy.


tell application system events at mouse location might be the key regarding the script, could you give me your settings/script that you do this with in btt please?

Nov 16, 2020 8:28 AM in response to GGarrett2

You can click with command down to open in a new tab or window depending on how the browser is set. Though there is a command in Applescript:


tell application "System Events" to click at the mouseLocation


it doesn't help because you can't specify command down, and also you can't trigger Applescript with a keystroke.


I do this on my trackpad with 'BetterTouchTool', specifying the browser and setting 'Three Finger Swipe Right' to execute CMD+click. I also do it on my trackball using USB Overdrive and setting right-click (actually left-click becaue I'm left-handed) to do this in a specified browser only. In both cases there are of course other options.


Neither will run on a keystroke but you can set Keyboard Maestro to do this: it's a powerful automation tool which can carry out complex tasks on a keystroke.


All three will run on Catalina.


However I'm not sure you can use a link to change what's in an existing window - there are methods in web page coding to do this in certain circumstances (e.g. frames) but that's not what you are talking about.

Nov 16, 2020 8:41 AM in response to GGarrett2

Applescript is not involved with BTT:



Firefox (I'm not using Chrome) has a prefs setting 'Open links in tabs instead of new windows' but even with this unchecked command-click is still opening a link in an new tab. You canof course use the right-click menu which has a choice of new tab or new window, but again that's not what you want. I don't see any easy way of opening the linked-to page in an existing window.


In KB you could probably set a macro to copy the URL of the link, bring the other window to the front, paste the URL into the address bar (after clearing whatever was there before) and hit return. I've not tried this actual process though I have used the paste-and-return bit of it in another process.

Nov 16, 2020 4:12 PM in response to GGarrett2

OK, what am I missing here? This is trivial to do with AppleScript:


tell application "Google Chrome"
	set theURL to URL of active tab of window 1
	tell window 2
		make new tab at end of tabs with properties {URL:theURL}
	end tell
end tell


The script grabs the current URL of the front window, then opens a new tab in the second window that that URL. Isn't that what you asked for?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Google chrome two windows, pushing link from one to another with applescript, hard or easy?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.