0
votes

The Run function doesn't work as expected on a URL inside of a variable.

I'm trying to clean up a script I've written that makes shortcuts for different websites. To let chrome navigate to a specific website I would write for example:

Run, "https://google.com"

Which works.

I've tried however to write a function with parameters to make the script more efficient but it isn't working.

goToSite(site) {
 Run, site
}
goToSite("https://google.com")

Expected result: Chrome navigates to specified URL

Actual result: "The system cannot find the file specified."

1

1 Answers

2
votes

In commands (Run, Send etc.) you have to enclose the variables in percent signs:

goToSite(site){
    Run, %site%
}
goToSite("https://google.com")

See https://www.autohotkey.com/docs/Tutorial.htm#s61