Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Solved] Installing AHK and Assoc. file with script



  • Please log in to reply
2 replies to this topic
Pinkfloydd
  • Members
  • 75 posts
  • Last active: May 31 2019 02:43 AM
  • Joined: 01 Jul 2012
Hi!

Posted Image

I was looking a way to do a simple install of Autohotkey.exe and then Associate the file .ahk to windows. Acually i do this:
-The script copies a folder that is in the same directory of the Script compiled, and then paste it into ProgramFiles. (The folder have the Autohotkey.exe program)
-Next I add some RegWrites for Associating .ahk to Autohotkey.exe that is in the new folder of ProgramFiles

; (Value not established) = ""
; NOTEPAD

;FOLDER COPY
FileCopydir, %A_ScriptDir%\AutoHotkey, %A_ProgramFiles%\AutoHotkey, 1              ;   1 mean OverWrite
FileCopy, %A_ScriptDir%\AutoHotkey\AutoHotkey.exe, %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe, 1


; EXTENSION .AHK
RegWrite, REG_sz, HKEY_CLASSES_ROOT, .ahk, , AutoHotkeyScript
RegWrite, REG_sz, HKEY_CLASSES_ROOT, .ahk\ShellNew, 
RegWrite, REG_sz, HKEY_CLASSES_ROOT, .ahk\ShellNew, FileName, Template.ahk


; AUTOHOTKEY SCRIPT
RegWrite, REG_sz, HKEY_CLASSES_ROOT, AutoHotkeyScript, , AutoHotkey Script
RegWrite, REG_sz, HKEY_CLASSES_ROOT, AutoHotkeyScript\DefaultIcon, , %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe,1
RegWrite, REG_sz, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell, , Open
RegWrite, REG_sz, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit, , Edit Script
RegWrite, REG_sz, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command, , notepad.exe
; Should say            -->                                                 notepad.exe [color=#FF0000]%1[/color]
RegWrite, REG_sz, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Open, , Run Script 
RegWrite, REG_sz, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Open\Command, , "%A_ProgramFiles%\AutoHotkey\AutoHotkey.exe" 
; Should say            -->                                         "C:\Program Files (x86)\AutoHotkey\AutoHotkey.exe"[color=#FF0000] "%1" %*[/color]


; OTHERS
RegWrite, REG_sz, HKEY_CLASSES_ROOT, Local Settings\Software\Microsoft\Windows\Shell\MuiCache, %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe, AutoHotkey
RegWrite, REG_sz, HKEY_CURRENT_USER, Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache, %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe, AutoHotkey

The problem is that i cant Write these codes ( %1 and %1 "%* )
Because they are "variables" and don't let me write them well.


A fast solution that i used is to create a file .reg with this code, and then AutoHotkey.exe works good:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AutoHotkeyScript]
@="AutoHotkey Script"

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

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

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

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

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

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


But I dont want to use files .reg, im trying to do it all with the ahk script.
Then: How i cant write the ( %1 and %1 "%* ) into RegWrite??

Posted Image

Thanks

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
✓  Best Answer
You need to escape the % sign, like this:
notepad.exe [color=red]`[/color]%1
Also, you seem to be Spanish, so you need to type twice the "^ ` [" key, then delete the stray ` character.

Pinkfloydd
  • Members
  • 75 posts
  • Last active: May 31 2019 02:43 AM
  • Joined: 01 Jul 2012
Edit: ohhh it works!!

Thank you!! xD