Get help with using AutoHotkey and its commands and hotkeys
glen

Here is my code:

Code: Select all

``UrlDownloadToFile, https://autohotkey.com/download/1.1/version.txt, C:\AutoHotkey Latest Version.txt``
When I run it, nothing happens.

I have IE installed and I've tried disabling my antivirus. I have no clue why it's not working.

gregster
Posts: 2513
Joined: 30 Sep 2013, 06:48

It's a guess (because I don't know your system details), but the root directory is often protected from non-admin users... and scripts (you can try copying a text file there, a warning box might appear). Either choose another directory ('Documents' or something you are allowed to write to) or try to run the script as 'admin'...
Last edited by gregster on 21 Jul 2018, 10:00, edited 1 time in total.
garry
Posts: 1825
Joined: 22 Dec 2013, 12:50

EDIT
Gregster wrote : this is it
...but the root directory is often protected from non-admin users... and scripts (you can try copying a text file there, a warning box might appear).
Either choose another directory ('Documents' or something you are allowed to write to) or try to run the script as 'admin'...
maybe also try with wget.exe
or

Code: Select all

``````f1=%a_scriptdir%\version.txt
return
``````
or this

Code: Select all

``````f1:="https://autohotkey.com/download/1.1/version.txt"
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET",F1, true)
whr.Send()
; Using 'true' above and the call below allows the script to remain responsive.
whr.WaitForResponse()
version := whr.ResponseText
MsgBox % version
return
``````

Code: Select all

``````  If ( not A_IsAdmin and not TaskExists )  {
CLine       := ( A_IsCompiled ? A_ScriptFullpath  : """"  A_AhkPath """ """ A_ScriptFullpath """" )
Run *RunAs %CLine%, %A_ScriptDir%, UseErrorLevel
OutputDebug % "AHK| RunAsAdmin ErrorLevel is: " ErrorLevel ", A_LastError is: " A_LastError
if (ErrorLevel != "ERROR")
ExitApp
}

return
``````
Last edited by garry on 21 Jul 2018, 10:30, edited 1 time in total.
Guest

Telling it to run as an admin did the trick. Thank you!
Posts: 1231
Joined: 10 Feb 2014, 20:00

My guess is that it's a permission error trying to write into the root of C. Try this:

Code: Select all

``````UrlDownloadToFile, https://autohotkey.com/download/1.1/version.txt, C:\temp\AutoHotkey Latest Version.txt
``````
Of course, make sure that C:\temp\ exists and that you have write permission to it. The code above works perfectly here on W7 and W10. Regards, Joe

Edit: Oops...there were no other posts when I answered, but when I hit Submit, several appeared. Sorry for the dup.
garry
Posts: 1825
Joined: 22 Dec 2013, 12:50