Always Opening a Link in a New Browser Tab Topic is solved
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Always Opening a Link in a New Browser Tab
When I use the Run command to open an URL link in the Opera browser, the link is usually opened in a new tab. But AutoHotkey also often causes Opera to open a link in a new window rather than a new tab. Does anyone know how to prevent this from happening?
Re: Always Opening a Link in a New Browser Tab
You can post your script below. If you use Run with just the URL alone, it would open in a new tab.
If your Windows registry has been altered from the default to handle URLs differently, you might get a different result.
Code: Select all
Run, http://www.autohotkey.com/
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
When I execute the command Run, http://www.autohotkey.com, the Opera browser opens the link in a new tab. However, links are not always opened in new tabs. For example, when I open https://mail.google.com/mail/u/0/#inbox , it is sometimes opened in a new window without any obvious reasons, but at other times, in a new tab. Does this have to do with system permissions which AutoHotkey has in regard to how it interacts with programs?mikeyww wrote: ↑15 May 2022, 14:00You can post your script below. If you use Run with just the URL alone, it would open in a new tab.
If your Windows registry has been altered from the default to handle URLs differently, you might get a different result.Code: Select all
Run, http://www.autohotkey.com/
Re: Always Opening a Link in a New Browser Tab
OK. I'm not sure why. I triggered:
three times, and it opened in a new tab each time.
If your current browser window is somehow not accessible to AutoHotkey, I suppose that it could open a new instance. Others here may have more information for you.
Code: Select all
F3::Run, https://mail.google.com/mail/u/0/#inbox
If your current browser window is somehow not accessible to AutoHotkey, I suppose that it could open a new instance. Others here may have more information for you.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
Yes, it is not clear why on my computer, AutoHotkey often opens links in new windows, although for the most part, it opens links in the same window in new tabs. The same link can be opened in either of the two ways in different instances.mikeyww wrote: ↑16 May 2022, 10:49OK. I'm not sure why. I triggered:
three times, and it opened in a new tab each time.Code: Select all
F3::Run, https://mail.google.com/mail/u/0/#inbox
If your current browser window is somehow not accessible to AutoHotkey, I suppose that it could open a new instance. Others here may have more information for you.
Perhaps the Opera browser (opera.exe) has to be specified as the program which receives the argument (the link). What command can be used to send the argument specifically to this browser?
Re: Always Opening a Link in a New Browser Tab
You can use Run, specify Opera as the target program, and then add the URL as a program parameter (after the program path)-- same as you would do on Windows command line.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
Thank you. I will try adding the program .exe file name before URLs to see whether the links will always be opening normally.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
I have added opera.exe before URLs. (E.g. Run opera.exe https://mail.google.com/mail/u/0/#inbox.)
But on some occasions and for no obvious reasons, links are still opened in new windows. This does not follow a particular pattern, because sometimes this happens, but often does not. I do not know what the exact reason may be.
But on some occasions and for no obvious reasons, links are still opened in new windows. This does not follow a particular pattern, because sometimes this happens, but often does not. I do not know what the exact reason may be.
Re: Always Opening a Link in a New Browser Tab
OK. I also do not know! Strange behavior. It seems to indicate that the original window is not identified or is tied up in a dialog, but I don't know what dialog that would be.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
I will add the command winactivate opera.exe before the Run [link] command to see whether a link will be opening in the same window if the window is activated first.
Re: Always Opening a Link in a New Browser Tab Topic is solved
I doubt that it would help. One workaround is to paste the URL into the browser's address bar instead of using Run.
Code: Select all
browser = ahk_exe chrome.exe
url = http://www.autohotkey.com/
#If WinExist(browser)
F2::
WinActivate
Send ^t
SoundBeep, 1500
SendInput {Text}%url%`n
Return
#If
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
Thank you. This is a clever way to resolve the issue. I was not aware that the Ctrl + T shortcut can be used to open a new tab and then simply paste an address into the address field. The same shortcut works in the Opera browser.mikeyww wrote: ↑21 May 2022, 11:18I doubt that it would help. One workaround is to paste the URL into the browser's address bar instead of using Run.
Code: Select all
browser = ahk_exe chrome.exe url = http://www.autohotkey.com/ #If WinExist(browser) F2:: WinActivate Send ^t SoundBeep, 1500 SendInput {Text}%url%`n Return #If
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
I have tried to run the following shorter test script for the Opera browser, but it does not work. Do you know what needs to be changed in it?
Code: Select all
space::
IfWinExist(ahk_exe opera.exe)
{
WinActivate ahk_exe opera.exe
Send ^{t}
SendInput {Text}http://www.autohotkey.com/`n
}
Return
Re: Always Opening a Link in a New Browser Tab
The AHK documentation is a great source of examples of each command and AHK function. You can give it a go when you run into issues like this.
IfWinExist is a deprecated command. WinExist is a function, which takes expressions.
Code: Select all
#IfWinExist ahk_exe opera.exe
Space::
WinActivate
Send ^t
SendInput {Text}http://www.autohotkey.com/`n
Return
#IfWinExist
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
Thank you. What is the purpose of the parameters {Text} and `n in the command SendInput {Text}http://www.autohotkey.com/`n?mikeyww wrote: ↑23 May 2022, 13:03Code: Select all
#IfWinExist ahk_exe opera.exe Space:: WinActivate Send ^t SendInput {Text}http://www.autohotkey.com/`n Return #IfWinExist
Re: Always Opening a Link in a New Browser Tab
If you remove `n, you will see the difference there, as `n is a line feed.
For text mode: https://www.autohotkey.com/docs/commands/Send.htm#SendText
You could get away without it for your specific URL here. If a URL contains a character that AHK would interpret as a special character, then text mode blocks that interpretation. You can try the URL in this post with and without text mode, to see how it works.
For text mode: https://www.autohotkey.com/docs/commands/Send.htm#SendText
You could get away without it for your specific URL here. If a URL contains a character that AHK would interpret as a special character, then text mode blocks that interpretation. You can try the URL in this post with and without text mode, to see how it works.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Always Opening a Link in a New Browser Tab
Thank you for the explanations. I can see that the {Text} command is needed, because without it, the script for the browser does not work as intended.mikeyww wrote: ↑23 May 2022, 13:26If you remove `n, you will see the difference there, as `n is a line feed.
For text mode: https://www.autohotkey.com/docs/commands/Send.htm#SendText
You could get away without it for your specific URL here. If a URL contains a character that AHK would interpret as a special character, then text mode blocks that interpretation. You can try the URL in this post with and without text mode, to see how it works.