SetBatchLines, 50ms InputBox, regpath, Enter Registry Path, Enter registry path to create AutoHotkey Script`, in the format:`n`nHKEY_CURRENT_USER\Software\TEST_APP`n%a_tab%%a_tab%OR`nHKEY_CURRENT_USER\\Software\\TEST_APP`n`n ifequal, regpath,, exitapp MsgBox, 4, Dynamic Registry?, Do you want the script to have Dynamic Registry?`n`nEg. Paths pointing to your windows folder will be converted to user's windows folder when they run the generated script. IfMsgbox, yes, setenv, Dynamic, Yes FileDelete, %A_ScriptDir%\reg.ahk StringReplace, regpath, regpath, \\, \, A StringGetPos, spos, regpath, \ StringLeft, Key, regpath, %spos% spos ++ StringTrimLeft, SubKey, regpath, %spos% Loop, %key%, %subkey%, 1, 1 { RegRead, A_Value StringReplace, A_Value, A_Value, `n, ``n, A StringReplace, A_Value, A_Value, `%, ```%, A StringReplace, A_Value, A_Value, `,, ```,, A StringReplace, A_Name, A_LoopRegName, `%, ```%, A StringReplace, A_Name, A_Name, `,, ```,, A IfEqual, Dynamic, Yes { StringReplace, A_Value, A_Value, %programfiles%, `%programfiles`%, A StringReplace, A_Value, A_Value, %windir%, `%windir`%, A StringReplace, A_Value, A_Value, %comspec%, `%comspec`%, A StringReplace, A_Value, A_Value, %CommonProgramFiles%, `%CommonProgramFiles`%, A StringReplace, A_Value, A_Value, %HOMEPATH%, `%HOMEPATH`%, A StringReplace, A_Value, A_Value, %USERPROFILE%, `%USERPROFILE`%, A StringReplace, A_Value, A_Value, %TEMP%, `%TEMP`%, A } IfNotEqual, A_LoopRegType, KEY, FileAppend, Regwrite`, %A_LoopRegType%`, %A_LoopRegKey%`, %A_LoopRegSubKey%`,%A_Name%`,%A_Value%`n, %A_ScriptDir%\reg.ahk }
Registry to AHK Script Convertor
Started by
Rajat
, Apr 21 2004 01:02 AM
3 replies to this topic
Just open regedit, rt. click a key and select 'copy key name'. run this script and paste key name when prompted. a file named 'reg.ahk' will be created in script's folder that'll recreate the whole registry key on the system its run on.
#1
-
Posted 21 April 2004 - 01:02 AM
CleanNews.in : Bite sized latest news headlines from India with zero bloat
I've updated the script above with the following changes:
-Spl characters in names/values are handled better.
-Added an option to allow the generated script to have 'Dynamic Registry'.
If the above option is selected, then a path like 'C:\Program Files\SomeFolder' in a value will be kept as '%ProgramFiles%\SomeFolder' in the generated script. this allows the scripts to support more target systems.
Paths kept dynamically are:
ProgramFiles
WinDir
Comspec
CommonProgramFiles
HomePath
UserProfile
Temp
It has given good results during my tests, but registry is a very complex architecture, so if anyone finds out that its not working correctly with some key/value... then plz let me know.
-Spl characters in names/values are handled better.
-Added an option to allow the generated script to have 'Dynamic Registry'.
If the above option is selected, then a path like 'C:\Program Files\SomeFolder' in a value will be kept as '%ProgramFiles%\SomeFolder' in the generated script. this allows the scripts to support more target systems.
Paths kept dynamically are:
ProgramFiles
WinDir
Comspec
CommonProgramFiles
HomePath
UserProfile
Temp
It has given good results during my tests, but registry is a very complex architecture, so if anyone finds out that its not working correctly with some key/value... then plz let me know.
#3
-
Posted 21 April 2004 - 09:19 AM
CleanNews.in : Bite sized latest news headlines from India with zero bloat
Very helpful script, thank you. I had a previous script that generated friendly filenames from any text - and so I integrated that so that this script now produces a file corresponding to the registry key. Also, the Reg Keys are reduced from their long form to their short form (i.e. HKEY_LOCAL_MACHINE is HKLM) for easier readability.
Also, you can run it via command-line now and skip the GUI by passing it the reg key as a parameter.
#NoTrayIcon Menu, Tray, Icon, %windir%\regedit.exe, 0 ; Check for Command line Parameters If(%0%) { ;If command line parameter regpath = %1% ; Get the first parameter Goto, LabelSkipGUI } InputBox, regpath, RegistryToAHK, Create AutoHotkey RegWrite script from registry key values. Valid entry examples:`n`nHKEY_CURRENT_USER\Software\TEST_APP`nHKEY_CURRENT_USER\\Software\\TEST_APP`nHKCU\Software\TEST_APP`nHKCU\\Software\\TEST_APP`n`n, ,600 LabelSkipGUI: ifequal, regpath,, exitapp ;MsgBox, 4, Dynamic Registry?, Do you want the script to have Dynamic Registry?`n`nEg. Paths pointing to your windows folder will be ;converted to user's windows folder when they run the generated script. ;IfMsgbox, yes, setenv, Dynamic, Yes setenv, Dynamic, Yes ; Generate friendly filename from regpath by replacing all special characters StringReplace, filename, regpath, HKEY_LOCAL_MACHINE, HKLM, All StringReplace, filename, filename, HKEY_CURRENT_USER, HKCU, All StringReplace, filename, filename, HKEY_CLASSES_ROOT, HKCR, All StringReplace, filename, filename, `r`n, %A_Space%, All ;replace newlines with spaces StringReplace, filename, filename, /, -, All StringReplace, filename, filename, \, -, All StringReplace, filename, filename, :, -, All StringReplace, filename, filename, », -, All StringReplace, filename, filename, ~, -, All StringReplace, filename, filename, •, -, All filename := RegExReplace(filename, "-+", "-") ;remove double dash filename := RegExReplace(filename,"[^[:alnum:][:space:]-(),.]") ;remove all but desired filename characters filename := RegExReplace(filename, "[[:blank:]]+", " ") ;remove double space filename = %filename% ;autotrim leading and trailing whitespaces StringLeft, filename, filename, 80 FileDelete, %A_ScriptDir%\%filename%.ahk StringReplace, regpath, regpath, \\, \, A StringGetPos, spos, regpath, \ StringLeft, Key, regpath, %spos% spos ++ StringTrimLeft, SubKey, regpath, %spos% Loop, %key%, %subkey%, 1, 1 { RegRead, A_Value StringReplace, A_Value, A_Value, `n, ``n, A StringReplace, A_Value, A_Value, `%, ```%, A StringReplace, A_Value, A_Value, `,, ```,, A StringReplace, A_Name, A_LoopRegName, `%, ```%, A StringReplace, A_Name, A_Name, `,, ```,, A ;Replace the RegKey to their short forms for easier readability StringReplace, A_RegKey, A_LoopRegKey, HKEY_LOCAL_MACHINE, HKLM, All StringReplace, A_RegKey, A_RegKey, HKEY_CURRENT_USER, HKCU, All StringReplace, A_RegKey, A_RegKey, HKEY_CLASSES_ROOT, HKCR, All IfEqual, Dynamic, Yes { StringReplace, A_Value, A_Value, %programfiles%, `%programfiles`%, A StringReplace, A_Value, A_Value, %windir%, `%windir`%, A StringReplace, A_Value, A_Value, %comspec%, `%comspec`%, A StringReplace, A_Value, A_Value, %CommonProgramFiles%, `%CommonProgramFiles`%, A StringReplace, A_Value, A_Value, %HOMEPATH%, `%HOMEPATH`%, A StringReplace, A_Value, A_Value, %USERPROFILE%, `%USERPROFILE`%, A StringReplace, A_Value, A_Value, %TEMP%, `%TEMP`%, A } IfNotEqual, A_LoopRegType, KEY, FileAppend, Regwrite`, %A_LoopRegType%`, %A_RegKey%`, %A_LoopRegSubKey%`,%A_Name%`,%A_Value%`n, %A_ScriptDir%\%filename%.ahk }
#4
-
Posted 01 February 2013 - 05:28 PM