Autohotkey, open URL in browser

By | 2022/03/10
 ; Autohotkey, open URL in the default-browser,
 ; a "little dirty" trick

; opening a local file with browser
; (the one which is registered to open local html-files)
; this file contains the javascript command "document.location.href" to open the url

url := "https://www.jvr.de"

; a temporary file, running directory must be writeable
outputFile := "a$$$$$$.html"
if (FileExist(outputFile))
    FileDelete, %outputFile%

FileAppend,
(
<html>
<body>
<script>
document.location.href="
),%outputFile%
FileAppend,%url%,%outputFile%
FileAppend,
(
"
</script>
</body>
</html>
),%outputFile%

cmdToRun := "cmd /c " . outputFile
run, %cmdToRun%

sleep,5000

; remove temporary file
if (FileExist(outputFile))
    FileDelete, %outputFile%e


;A simpler way is to just send some keystrokes using the Windows RUN hotkey,
example:
url := "http://www.jvr.de"
sendinput, #r
sleep, 1000
sendinput, %url%{ENTER}