Open webpages from an ahk button

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Shoal
Posts: 24
Joined: 26 Jul 2017, 16:28

Open webpages from an ahk button

27 Jul 2017, 12:56

I was wondering if anyone could help me with some code to open a website when a button is pressed on the GUI.
for example, I want a button like this:

Code: Select all

Gui, Add, Button, x5 y50 w200 h20 ,Example
to open a website.
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Open webpages from an ahk button

27 Jul 2017, 13:25

Code: Select all

#SingleInstance, Force

Gui, Margin, 5, 5
Gui, Add, Button, x5 y50 w200 h20 gButton1, Example
Gui, Show, AutoSize, Example
return

Button1:
    Run, http://www.google.com/
return
GenericEntity

Re: Open webpages from an ahk button

27 Jul 2017, 13:26

You need to attach a subroutine to the GUI command in the options for this to work:

Code: Select all

Gui, Add, Button, x5 y50 w200 h20 gRun, Example ; gRun tells the button to run the subroutine "Run" when it is pressed
Gui, Show ; Shows the GUI button
return ; Stops the script from running the webpage before the button is pressed

Run: ; Specifies the start of your subroutine
Run, https://www.google.com ; Opens google.com in your default web browser

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 351 guests