<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: RegFile2Ahk Converter помощь]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12060&amp;type=atom" />
	<updated>2016-10-04T19:14:47Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12060</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108214#p108214" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>freeZer0K пишет:</cite><blockquote><p>AHK: RegFile2Ahk Converter помощь</p></blockquote></div><p><span style="color: green"><strong>freeZer0K</strong>, <a href="http://forum.script-coding.com/viewtopic.php?id=5421">обратите внимание</a> на список слов, которые не следует употреблять в заголовках, приведите в порядок.</span></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-10-04T19:14:47Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108214#p108214</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108209#p108209" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>freeZer0K пишет:</cite><blockquote><p>Единственное что, этот шаблон бреет напрочь все</p></blockquote></div><p>А я спецом так сделал. Не понял, какой смысл в кавычках в первом пути, если их нет во втором.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-10-04T15:35:34Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108209#p108209</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108208#p108208" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong> !!! СПАСИБЫ !!! - ВОТ ТАКОЙ!</p><p>Немного не додумал шаблон .... теперь все намана!</p>]]></content>
			<author>
				<name><![CDATA[freeZer0K]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34228</uri>
			</author>
			<updated>2016-10-04T12:26:31Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108208#p108208</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108207#p108207" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>msgbox % VType := RegExReplace(VType, &quot;`a)&quot;&quot;(.*)&quot;&quot;=&quot;&quot;\\?(.+?)\\?&quot;&quot;&quot;, &quot;RegWrite REG_SZ, RegPath, $1, $2&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-10-04T12:22:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108207#p108207</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108206#p108206" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, благодарю, я так уже тестил - тоже оставляет последний \ , затем нужная &quot; ...</p><p>Думаю, не плавить мозги, все-равно пути потом менять на переменные в формат ahk, а в них добавить везде двойные кавычки , т.к. без &quot; винда обычно всегда лягается.</p>]]></content>
			<author>
				<name><![CDATA[freeZer0K]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34228</uri>
			</author>
			<updated>2016-10-04T12:01:50Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108206#p108206</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108205#p108205" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>msgbox % VType := RegExReplace(VType, &quot;`a)&quot;&quot;(.*)&quot;&quot;=&quot;&quot;\\?(.+)\\?&quot;&quot;&quot;, &quot;RegWrite REG_SZ, RegPath, $1, $2&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-10-04T11:53:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108205#p108205</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108204#p108204" />
			<content type="html"><![CDATA[<p>Блоагодарю, <strong>Flasher</strong>!<br />Единственное что, этот шаблон бреет напрочь все &quot;, а хотелось бы их оставить там, где путь указан с двойными кавычками, типа:<br />&quot;C:\\Program Files\\Notepad++\\notepad++.exe&quot;</p><p>В оригинале это строка 1 в переменной VType.</p><p>В строке 2 путь указан без &quot;<br />C:\\Program Files\\Registry Workshop\\RegWorkshop.exe</p><p>Благодарю за помощь!</p>]]></content>
			<author>
				<name><![CDATA[freeZer0K]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34228</uri>
			</author>
			<updated>2016-10-04T11:43:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108204#p108204</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108201#p108201" />
			<content type="html"><![CDATA[<p><strong>freeZer0K</strong><br />Такое выражение: <strong>&quot;`amU)&quot;&quot;(.*)&quot;&quot;=&quot;&quot;[&quot;&quot;\\]*?(.+)\\?&quot;&quot;*$&quot;</strong></p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-10-04T10:54:48Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108201#p108201</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108200#p108200" />
			<content type="html"><![CDATA[<p>1) Почитать как добавляются по-дефалту новые строки в continuation section.<br />2) Почитать про опцию s) в регулярных выражениях.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-10-04T09:55:47Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108200#p108200</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: RegFile2Ahk Converter помощь]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=108199#p108199" />
			<content type="html"><![CDATA[<p>Добрый день!</p><p>Начал скрипт - конвертер регфайлов (*.reg) в *.ahk и столкнулся с некоторыми проблемами.</p><p>Код скрипта:</p><div class="codebox"><pre><code>
#NoEnv
#NoTrayIcon
#SingleInstance force
SendMode Input
SetBatchLines -1

If !A_IsAdmin
	{
	Run % &quot;*RunAs &quot;&quot;&quot; A_ScriptFullPath &quot;&quot;&quot;&quot;
	ExitApp
	}
	
ProgramName := &quot;RegFile2Ahk Converter&quot;
/*
; SourceDir изменить

GetRegFile:
Title := &quot;Выбор файла реестра для конвертирования&quot;
FileSelectFile RegFile, 3, % SourceDir, % Title, Файлы реестра (*.reg)
If !RegFile
	{
	MsgBox 0x34, % ProgramName, Файл реестра не выбран!`n`nПовторить?
	IfMsgBox Yes
		{
		GoTo GetRegFile
		}
	IfMsgBox No
		{
		ExitApp
		}
	}
*/	
RegFile := A_ScriptDir &quot;\REGISTRY-TEST.reg&quot; ; строка к финальному удалению!

FileRead VType, % RegFile

; удаление Windows Registry Editor Version 5.00
VType := RegExReplace(VType, &quot;i)Windows Registry Editor Version.*?(\R+|$)&quot;)

; удаление пустых значений (по-умолчанию)
VType := RegExReplace(VType, &quot;@=&quot;&quot;&quot;&quot;(\R+|$)&quot;)

; @=&quot;бубль гум&quot; по-умолчанию (marker @=&quot;&quot; &gt; REG_SZ)
VType := RegExReplace(VType, &quot;@=&quot;&quot;(.*)&quot;&quot;&quot;, &quot;RegWrite REG_SZ, RegPath,, $1&quot;)

; &quot;this_is_REG_SZ&quot;=&quot;C:\\Program Files\\Registry Workshop\\RegWorkshop.exe&quot; (marker   =&quot; &gt; REG_SZ)
VType := RegExReplace(VType, &quot;&quot;&quot;(.*)&quot;&quot;=&quot;&quot;(.*)&quot;&quot;&quot;, &quot;RegWrite REG_SZ, RegPath, $1, $2&quot;)

; &quot;this_is_REG_DWORD&quot;=dword:00477579 (marker   =dword: &gt; REG_DWORD)
VType := RegExReplace(VType, &quot;&quot;&quot;(.*)&quot;&quot;=dword:(\d+)&quot;, &quot;RegWrite REG_DWORD, RegPath, $1, $2&quot;)

; &quot;this_is_REG_BINARY&quot;=hex:34,37,37,35,\ (marker   =hex: &gt; REG_BINARY)   !!!!!!!!!!
VType := RegExReplace(VType, &quot;&quot;&quot;(.*)&quot;&quot;=hex:(.*)\\(\R\s+|$)&quot;, &quot;RegWrite REG_BINARY, RegPath, $1, $2&quot;)

; &quot;this_is_REG_MULTI_SZ&quot;=hex(7):33,00,38,00,\ (marker   =hex(7): &gt; REG_MULTI_SZ)
VType := RegExReplace(VType, &quot;&quot;&quot;(.*)&quot;&quot;=hex\(7\):(.*)\\&quot;, &quot;RegWrite REG_MULTI_SZ, RegPath, $1, $2&quot;)

; &quot;this_is_REG_EXPAND_SZ&quot;=hex(2):22,00,43,00,\ (marker   =hex(2): &gt; REG_EXPAND_SZ)
VType := RegExReplace(VType, &quot;&quot;&quot;(.*)&quot;&quot;=hex\(2\):(.*)\\&quot;, &quot;RegWrite REG_EXPAND_SZ, RegPath, $1, $2&quot;)

; &quot;this_is_REG_QWORD&quot;=hex(b):34,37,37,35 (marker   =hex(b): &gt; REG_QWORD)
VType := RegExReplace(VType, &quot;&quot;&quot;(.*)&quot;&quot;=hex\(b\):(\d+)&quot;, &quot;RegWrite REG_QWORD, RegPath, $1, $2&quot;)

; удаляемые разделы
VType := RegExReplace(VType, &quot;i)\[-(HKEY_\w+)\\(.*)\](\R|$)&quot;, &quot;RegDelete $1, $2`n&quot;)
; удаляемые параметры
VType := RegExReplace(VType, &quot;m`a)(@=-.*)|(&quot;&quot;.*&quot;&quot;=-.*)&quot;, &quot;;$1$2`t- удаление параметров запрещено в Windows 10&quot;)


Loop parse, % VType, `n, `r
	{
	Loop
		{
		If A_LoopField contains [HKEY_
			{
			NewRegPath := RegPath(RegPathAhk) ; преобразование path реестра в формат ahk
			break
			}
			Else
				{
				RegStrAhk := A_LoopField
				If InStr(RegStrAhk, &quot;\\&quot;) ; замена double backslash на один и удаление \&quot; \&quot;  (проверить после правки шаблонов)
					{
					RegStrAhk := RegExReplace(StrReplace(RegStrAhk, &quot;\\&quot;, &quot;\&quot;, &quot;All&quot;), &quot;(.*)\\&quot;&quot;(\w:\\.*)\\&quot;&quot;&quot;, &quot;$1$2&quot;)
					}
				If InStr(RegStrAhk, &quot;Program Files&quot;) ; замена C:\Program Files на переменную
					{
					RegStrAhk := RegExReplace(RegStrAhk, &quot;(.*)\w:\\Program Files(.*)&quot;, &quot;$1 % ProgramFiles &quot;&quot;$2&quot;&quot;&quot;)
					}
				RegStrAhk := StrReplace(RegStrAhk, &quot;RegPath&quot;, NewRegPath, &quot;All&quot;) ; замена marker &quot;RegPath&quot; на реальный path AHK
				GoSub Print
				break
				}
		}
	}
	
ExitApp

Print:
SplitPath RegFile,,,, RegFileNoExt
FileAppend
	(
	% RegStrAhk &quot;`n&quot;
	), % RegFileNoExt &quot;.ahk&quot;, UTF-8
return

; functions
RegPath(RegPathAhk)
	{
	RegPathAhk := RegExReplace(A_LoopField, &quot;i)\[HKEY_CLASSES_ROOT\\(.*)\]&quot;, &quot;HKCR, $1&quot;)
	RegPathAhk := RegExReplace(RegPathAhk, &quot;i)\[HKEY_CURRENT_USER\\(.*)\]&quot;, &quot;HKCU, $1&quot;)
	RegPathAhk := RegExReplace(RegPathAhk, &quot;i)\[HKEY_LOCAL_MACHINE\\(.*)\]&quot;, &quot;HKLM, $1&quot;)
	Return RegPathAhk
	}
</code></pre></div><p>Тестовый файл реестра REGISTRY-TEST.reg:</p><div class="codebox"><pre><code>Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\TEST-1]
&quot;this_is_REG_SZ-1&quot;=&quot;\&quot;C:\\Program Files\\Notepad++\\notepad++.exe\&quot;&quot;
&quot;this_is_REG_SZ-2&quot;=&quot;C:\\Program Files\\Registry Workshop\\RegWorkshop.exe&quot;
&quot;this_is_REG_SZ-3&quot;=&quot;Shutdown;Reboot;Hibernate;LogOff&quot;</code></pre></div><br /><p>Тестовый код:</p><div class="codebox"><pre><code>VType =
(
&quot;this_is_REG_SZ-1&quot;=&quot;\&quot;C:\\Program Files\\Notepad++\\notepad++.exe\&quot;&quot;
&quot;this_is_REG_SZ-2&quot;=&quot;C:\\Program Files\\Registry Workshop\\RegWorkshop.exe&quot;
&quot;this_is_REG_SZ-3&quot;=&quot;Shutdown;Reboot;Hibernate;LogOff&quot;
)

msgbox % VType := RegExReplace(VType, &quot;`a)&quot;&quot;(.*)&quot;&quot;=&quot;&quot;\\?(.*)&quot;&quot;&quot;, &quot;RegWrite REG_SZ, RegPath, $1, $2&quot;)</code></pre></div><br /><p>Дает такой результат:</p><div class="codebox"><pre><code>
RegWrite REG_SZ, RegPath, this_is_REG_SZ-1, &quot;C:\\Program Files\\Notepad++\\notepad++.exe\&quot;
RegWrite REG_SZ, RegPath, this_is_REG_SZ-2, C:\\Program Files\\Registry Workshop\\RegWorkshop.exe
RegWrite REG_SZ, RegPath, this_is_REG_SZ-3, Shutdown;Reboot;Hibernate;LogOff
</code></pre></div><p>Задача этого шаблона преобразовать все строки переменной VType в такие:</p><div class="codebox"><pre><code>RegWrite REG_SZ, RegPath, this_is_REG_SZ-1, &quot;C:\\Program Files\\Notepad++\\notepad++.exe&quot;
RegWrite REG_SZ, RegPath, this_is_REG_SZ-2, C:\\Program Files\\Registry Workshop\\RegWorkshop.exe
RegWrite REG_SZ, RegPath, this_is_REG_SZ-3, Shutdown;Reboot;Hibernate;LogOff</code></pre></div><p>Как удалить последний \ в строке ... notepad++.exe\&quot;?</p>]]></content>
			<author>
				<name><![CDATA[freeZer0K]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34228</uri>
			</author>
			<updated>2016-10-04T09:15:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=108199#p108199</id>
		</entry>
</feed>
