McDubs
McDubs

Reputation: 1

Trying to create a line of code that opens the default web browser and launches a site using a Command

So currently i have a Hotkey command of CTRL + ALT + 2 that will fill in the web address bar or where every my stylist is pointing and put in the website that i want.

I am trying to make it more like a command that can launch the default browser and then open up the webpage for like a speed test link.

Any help would be appreciated, it's not really a line of code so I'll put it down below, hopefully that's fine for the forums I'm still new here and trying to learn.

!^2:: SendInput, https://speed.cloudflare.com/ return

I have not really tried anything to make it more efficient.

Upvotes: 0

Views: 62

Answers (2)

Thierry Dalon
Thierry Dalon

Reputation: 926

Using the Run command followed by the Url will open the Url in your default browser. See https://www.autohotkey.com/docs/v1/lib/Run.htm#ExURL

So this code shall do want you are looking for

!^2:: Run, https://speed.cloudflare.com/ 

Upvotes: 0

Ralf_Reddings
Ralf_Reddings

Reputation: 1533

You could achieve this using the command line facility of your browser. Since you did not specify your browser, I will share an example with Firefox but can be easily changed to a chromium browser etc:

!^2::
run, firefox -new-tab  https://speed.cloudflare.com/
return

The above does rely on your browser being in your PATH env, you could also explicitly point to your browsers executable, as in the following case:

!^2::
run, C:\Program Files\Mozilla Firefox\firefox.exe -new-tab  https://speed.cloudflare.com/
return

Both examples make use of the -new-tab parameter to tell Firefox to open https://speed.cloudflare.com/ in a new tab.

I should note though that this will open the address in a new tab, I am not sure if that is your goal.

Upvotes: 1

Related Questions