AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Registry to AHK Script Convertor

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Wed Apr 21, 2004 2:02 am    Post subject: Registry to AHK Script Convertor Reply with quote

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.

Code:
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
}

_________________


Last edited by Rajat on Wed Apr 21, 2004 10:18 am; edited 1 time in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Wed Apr 21, 2004 2:23 am    Post subject: Reply with quote

Nice, this will come in handy.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Wed Apr 21, 2004 10:19 am    Post subject: Reply with quote

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.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group