Script will not run

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Script will not run

18 Aug 2018, 08:28

Hi. I just downloaded AHK onto a new computer. After I created and saved a script (saved as .ahk), I did a right click on the AHK app icon. On my old computer, a list of options popped up with Run Script at the top. After clicking Run Script, the program worked. But now, there is no such option. When I try to run the script, the options are Open, Open File Location, Run as Administrator, Troubleshoot Compatibility, etc. When I double click on the icon or select Open or Run as Addministrator, a help program opens. How can I get this to Run Script? I have followed all instructions and watched the video (and successfully run this program on my last computer). Any help would be appreciated.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

18 Aug 2018, 11:55

How looks your script ?
an example
use a texteditor like notepad or notepad++ ,save this as xy.ahk, doubleclick to run , nothing happens , you must then use the button F2 to start

Code: Select all

$F2::
wa:=A_screenwidth
ha:=A_screenHeight
aac=%a_osversion% `n %a_ostype% `n 64bit=%a_is64bitos% `n %wa%*%ha% `n %a_username%=%a_isadmin% `n %a_computername%
msgbox, 262208, ,%aac%
return
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

18 Aug 2018, 12:04

I don't quite follow.

When I open an AutoHotkey Script from Desktop, the following appears at the top of the texteditor (Notepad):

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

Not sure what any of that means, but something very similar appeared when I used the program on my old computer.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

18 Aug 2018, 12:37

these are the first basic recommended lines ( like default commands )
I just added to this example , doubleclick to start

Code: Select all

#NoEnv                         ;- Recommended for performance and compatibility with future AutoHotkey releases.
#Warn                          ;- Enable warnings to assist with detecting common errors.
#Singleinstance,force          ;- like RELOAD , if start script again didn't ask you that it's already started
SendMode Input                 ;- Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%    ;- Ensures a consistent starting directory.
;return

;$F2::                         ;- this is a disactivated line ( example hotkey F2 to start if needed )
wa:=A_screenwidth
ha:=A_screenHeight
aac=%a_osversion% `n %a_ostype% `n 64bit=%a_is64bitos% `n %wa%*%ha% `n %a_username%=%a_isadmin% `n %a_computername%
msgbox, 262208, ,%aac%
return
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

18 Aug 2018, 12:52

Garry, I still am not following. I have no idea what I'm supposed to do with this. (You probably need to adjust and talk down to me!)

I did, just as a guess, copy your code into the text editor and saved it as .ahk. But the app icon, which I right-click on it, still does not give a Run option.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

18 Aug 2018, 13:02

ok, dont't know why 'Run Script' is missing by rightclick
but you can run it at least with a doubleclick ? ( Otherwise must define in windows 'Always open with' the ahk- extension )
maybe deinstall and run 'Download Autohotkey Installer ' again (?)
https://autohotkey.com/download/
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

18 Aug 2018, 13:10

Both double click and right click give the same set of otions: Open, Open in File Location, Run as Administrator, etc. This is frustrating because, as I said, I had no problems when using this program on my last computer.

I suppose I can always try to reinstall, as you suggest. But thanks for looking into it. I appreciate it.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

18 Aug 2018, 13:19

maybe if you're not admin , you can't copy files to C:\ etc ...
the msgbox example above shoul'd work without problem

an example to run as admin

Code: Select all

;- start as admin cmd.exe
MsgBox, % "I am" (A_IsAdmin ? "" : " not") " Admin."
Gosub, RunAsAdmin1
;-----------
run, %comspec% /k date /T&time /T&time  ;<<<  your command here to change the time ( use ENTER for nothing )
;run, %comspec% /k sfc /scannow
;-----------
Return
;--------------------------------------------------------------------

RunAsAdmin1:
If Not A_IsAdmin 
{
try
	    {
        Run, *RunAs %A_ScriptFullPath%
        }
Exitapp		
}		
Return
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

18 Aug 2018, 13:32

Garry, I'm really sorry, and I am not trying to be difficult (especially when you are helping me!) but I have no idea what you are asking me to do. I don't know what a msgbox is or where the first example the you refer to is. I don't know what you are suggesting I do with the code you are sending. I can copy this code into the .ahk text and save it (I do know how to do that, and I did do that with the first code you sent), but it won't run becuase I cannot get the app to give me a Run Script option.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

18 Aug 2018, 13:45

ok, I think somebody can help ...... ( If long time no answer ask again )
TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Script will not run

18 Aug 2018, 18:48

Robert; perhaps we need to go back to basics, if you don't mind. Could you tell us how you installed AHK? Did you download the .zip or the .exe? (The .exe contains the full installer and is downloaded by clicking on the blue-ish button near the top of the download page - not immediately obvious unfortunately.)
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

20 Aug 2018, 06:18

Hi, Tac.
Initially, I tried the .exe. I kept receiving an Error 404 page. So then I downloaded the .zip file. I could not get the .zip file to run at all, that is, I could not figure out how to install the program once the zip file was downloaded. The next day, I tried the .exe file again, which then worked (apparently, the problem causing the error page was fixed).

If you look at the first picture from my screen I attached, you can see the app icon for AutohotKey, green with an H on it, and the shortcut to the script I am trying to run. The second shows the menu when I right click on the app icon. To repeat what I wrote above, when I tried to use this on my previous computer, I had no problem. When I would right click on the app icon, the popup menu began with Run Script.
Attachments
Capture.PNG
(76.83 KiB) Downloaded 147 times
Capture2.PNG
(390.35 KiB) Downloaded 147 times
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

20 Aug 2018, 06:57

-"AutoHotKey.lnk" < this is a link/shortcut , you don't need this at desktop
( when I click on this I see the same )

-"New AutoHotKey Script.txt" < this is a text-file ( notepad)
Ahk-script it must be renamed e.g. to > "Test.ahk" , ( shoul'd have the ahk-icon ) / not "Test.ahk.txt" , sometimes you can't see the extension , see windows settings
To start ahk-script, doubleclict ahk-script , example > "Test.ahk"
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

20 Aug 2018, 08:41

I do understand that the icon is just a shortcut, but the shortcut is to "C:\Program Files\AutoHotkey\AutoHotkey.exe", the actual program.

The script is a .ahk type of file, as the picture shows. When I save it, I select the All Files option under Save as Type, type ".ahk" as the file extension, and have the Encoding set to UTF-8 (I have no idea what this last thing is, but the tutorial video said to be sure that the encoding was set to this.
Attachments
Capture3.PNG
(14.06 KiB) Downloaded 126 times
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

20 Aug 2018, 08:44

Here is the settings when I save the textfile.
Attachments
Capture4.PNG
(6.48 KiB) Not downloaded yet
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

20 Aug 2018, 09:54

strange , I don't know why you don't get the ahk-icon as xy.ahk , at the moment it opens with notepad ( like text )
try to 'always open with' > use Change-Button and select Autohotkey.exe ( maybe must search in explorer Programs )
I have 64-bit computer ( selected 'Autohotkey Unicode 64-bit' always open with )
( ... or maybe other users can better help )
Robert
Posts: 9
Joined: 17 Aug 2018, 21:22

Re: Script will not run

20 Aug 2018, 10:26

OH MY GOSH GARRY THAT DID IT! I works now. Thank you, thank you, thank you.

I right-clicked on the text editor icon, the one labeled New AutoHotKey Script. I selected Open With-->Choose another app-->AutoHotKey Unicode 64 bit, click on Always open with this app, and PRESTO!

I wish I could buy you a beer.

Anyway, I should point out that the step that you pointed me to I don't recall ever seeing in the tutorials, videos, help docs. Maybe everyone else knows what I missed already. But at least it's running.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

20 Aug 2018, 10:40

@Robert, glad it works
I like wheat beer :)
https://en.wikipedia.org/wiki/Hoegaarden_Brewery
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Script will not run

20 Aug 2018, 10:43

1. go to the official download link: https://autohotkey.com/download/ahk-install.exe
2. download the 1.1.29.01 .exe installer again
3. run the installer as administrator, hit 'uninstall' if shown and proceed with the uninstallation
4. if 'uninstall' doesnt appear, hit 'install' and install the unicode x64 version

if u still dont have the context menu items, likely something is preventing the installer from writing the necessary keys in the registry. u may opt to enter them manually instead. check if the file paths match:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AutoHotkeyScript]
@="AutoHotkey Script"

[HKEY_CLASSES_ROOT\AutoHotkeyScript\DefaultIcon]
@="C:\\Program Files\\AutoHotkey\\AutoHotkey.exe,1"

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell]
@="Open"

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Compile]
@="Compile Script"

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Compile\Command]
@="\"C:\\Program Files\\AutoHotkey\\Compiler\\Ahk2Exe.exe\" /in \"%l\""

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit]
@="Edit Script"

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command]
@="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Open]
@="Run Script"

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Open\Command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"%1\" %*"

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\RunAs]

[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\RunAs\Command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"%1\" %*"

garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Script will not run

20 Aug 2018, 11:04

thank you swagfag
here again msgbox example ( some computer-info )

Code: Select all

#NoEnv                         ;- Recommended for performance and compatibility with future AutoHotkey releases.
#Warn                          ;- Enable warnings to assist with detecting common errors.
#Singleinstance,force          ;- like RELOAD , if start script again didn't ask you that it's already started
SendMode Input                 ;- Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%    ;- Ensures a consistent starting directory.
;return
;$F2::                         ;- this is a disactivated line ( example hotkey F2 to start if needed )
wa:=A_screenwidth
ha:=A_screenHeight
aac=OS-Version=%a_osversion%`nOS-Type=%a_ostype%`n64bit=%a_is64bitos%`nScreen=%wa%*%ha%`nUsername=%a_username%`nIsAdmin=%a_isadmin%`nComputername=%a_computername%`nAHK-Version=%a_ahkversion%
msgbox, 262208,Computer-Info,%aac%
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AHK_user and 247 guests