Use modifier key to toggle between launching script vs editing script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Use modifier key to toggle between launching script vs editing script

20 Apr 2019, 00:02

In Windows Explorer, how do I use a modifier key (e.g. holding down Alt when double-clicking on .ahk file) to tell it to launch notepad instead of the script itself?
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Re: Use modifier key to toggle between launching script vs editing script

21 Apr 2019, 18:11

You don't.

You can use a modifier key to tell the script to launch Notepad and then exit. Just use If and GetKeyState.

But you can't use Alt. Holding Alt will tell Explorer to invoke a Properties dialog instead of opening the file.

You can override the "properties" verb via the registry. Interestingly, doing so will remove the "Properties" item which normally appears at the bottom of the context menu, but Alt-double-clicking will still open the Properties dialog (as will clicking the Properties button on the ribbon in Windows 10). This might be useful to know when dealing with malware...
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: Use modifier key to toggle between launching script vs editing script

03 May 2019, 04:21

Noted for the If and GetKeyState functions, but what I don't understand is how to specify the AHK to be edited in notepad (instead of running the script) when the modifier key(e.g. SHIFT) key is held down while double clicking on .ahk.
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Use modifier key to toggle between launching script vs editing script

03 May 2019, 09:13

Is right clicking=>Edit more difficult that holding shift and double clicking
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Use modifier key to toggle between launching script vs editing script

03 May 2019, 10:12

You could change the file association for .ahk files to your own compiled script which only purpose is to capture the command line parameters and pass is on to the actual autohotkey.exe unless your modifier is held down, in which case it either redirects is to your editor or prepends the command line with edit.

I've done something similar to the url-protocol, so certain domains are opened in a different browser.
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Re: Use modifier key to toggle between launching script vs editing script

09 May 2019, 18:51

There's no need to use a compiled script. You can use "Path\to\AutoHotkey.exe" "Path\to\script.ahk" "%1" %* instead of "Path\to\script.exe" "%1" %*.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Use modifier key to toggle between launching script vs editing script

10 May 2019, 10:27

I use Shift+Enter to open a file/folder with a secondary program:
Quicker way to open script file for editing - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=26638
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 198 guests