<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17460&amp;type=atom" />
	<updated>2022-11-11T11:02:16Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17460</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155595#p155595" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Gh0sTG0 пишет:</cite><blockquote><p>не вижу тут проверки на то, что юрл есть в файле?</p></blockquote></div><p>Можно добавить такую проверку после FileRead.<br /></p><div class="quotebox"><cite>Gh0sTG0 пишет:</cite><blockquote><p>я это зря с return false нагородил, и оно и так было бы False при отсутствии return&#039;а?</p></blockquote></div><p>Так и есть.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-11-11T11:02:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155595#p155595</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155594#p155594" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Один маленький вопрос: я не вижу тут проверки на то, что юрл есть в файле? Или оно как то по хитрому обработается?<br />Это типа как то так?<br /></p><div class="codebox"><pre><code>
result := FindUrl(obj, url)
if (result)
	MsgBox, %result%
else
	MsgBox, Насяльника! Усе пропала! Адреса пропала!

FindUrl(obj, url, folderPath := &quot;&quot;) {
	if (obj.type = &quot;url&quot; &amp;&amp; obj.url = url)
		Return folderPath
	else if (obj.type = &quot;folder&quot;)
	{
		folderPath .= (folderPath = &quot;&quot; ? &quot;&quot; : &quot;\&quot;) . obj.name
		for k, v in obj {
			if IsObject(v) &amp;&amp; p := FindUrl(v, url, folderPath)
				Return p
		}
	} else {
   		Return False
	}
}</code></pre></div><br /><p>------------------------------------------------------------<br />Вот сейчас читаю код, и кажется я это зря с return false нагородил, и оно и так было бы False при отсутствии return&#039;а?</p>]]></content>
			<author>
				<name><![CDATA[Gh0sTG0]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39523</uri>
			</author>
			<updated>2022-11-11T10:22:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155594#p155594</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155592#p155592" />
			<content type="html"><![CDATA[<p>И вам спасибо, что не забываете ставить точки, а если забываете, то быстро исправляете.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-11-11T08:08:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155592#p155592</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155591#p155591" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Gh0sTG0]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39523</uri>
			</author>
			<updated>2022-11-11T07:53:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155591#p155591</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155589#p155589" />
			<content type="html"><![CDATA[<p>Можно и распарсить, у меня так вышло:<br /></p><div class="codebox"><pre><code>#NoEnv
SetBatchLines, -1

filePath := A_AppData . &quot;\..\Local\Google\Chrome\User Data\Default\Bookmarks&quot;
url := &quot;https://forum.script-coding.com/&quot;
FileRead, json, % &quot;*P65001 &quot; . filePath
obj := JsonToAHK(json)
MsgBox, % FindUrl(obj, url)

FindUrl(obj, url, folderPath := &quot;&quot;) {
   if (obj.type = &quot;url&quot; &amp;&amp; obj.url = url)
      Return folderPath
   if (obj.type = &quot;folder&quot;)
      folderPath .= (folderPath = &quot;&quot; ? &quot;&quot; : &quot;\&quot;) . obj.name
   for k, v in obj {
      if IsObject(v) &amp;&amp; p := FindUrl(v, url, folderPath)
         Return p
   }
}

JsonToAHK(json, rec := false) {
   static doc := ComObjCreate(&quot;htmlfile&quot;)
         , __ := doc.write(&quot;&lt;meta http-equiv=&quot;&quot;X-UA-Compatible&quot;&quot; content=&quot;&quot;IE=9&quot;&quot;&gt;&quot;)
         , JS := doc.parentWindow
   if !rec
      obj := %A_ThisFunc%(JS.JSON.parse(json), true)
   else if !IsObject(json)
      obj := json
   else if JS.Object.prototype.toString.call(json) == &quot;[object Array]&quot; {
      obj := []
      Loop % json.length
         obj.Push( %A_ThisFunc%(json[A_Index - 1], true) )
   }
   else {
      obj := {}
      keys := JS.Object.keys(json)
      Loop % keys.length {
         k := keys[A_Index - 1]
         obj[k] := %A_ThisFunc%(json[k], true)
      }
   }
   Return obj
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-11-11T00:33:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155589#p155589</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155588#p155588" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Gh0sTG0 пишет:</cite><blockquote><p>Ну, или все же можно как то подцепиться к элементу gui и вынуть его текст?</p></blockquote></div><p>Через iaccessible.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2022-11-10T23:08:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155588#p155588</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155587#p155587" />
			<content type="html"><![CDATA[<p><strong>ypppu</strong><br />Я его уже нашел. Точнее даже не так, я уже через него проверяю есть ли там закладка. Мне как то тут же посоветовали. (спасибо тов. Malcev&#039;у)<br />Но у меня не хватает мозгов понять как его правильно спарсить... Там типа в двух разных местах пишутся папка и закладка, и как пройти от юрла закладки куда то сильно вверх до названия папки...<br />Ну, или все же можно как то подцепиться к элементу gui и вынуть его текст?</p><p>PS а можно просто пересоздавать закладку, предварительно выбрав нужную папку, да. Метод, конечно, тот еще, но как костыль сойдет.</p>]]></content>
			<author>
				<name><![CDATA[Gh0sTG0]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39523</uri>
			</author>
			<updated>2022-11-10T20:14:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155587#p155587</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155586#p155586" />
			<content type="html"><![CDATA[<p>У меня файл &quot;Bookmarks&quot; лежит в AppData\Local\Google\Chrome\User Data\Default. Наверное можно запарсить.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2022-11-10T20:09:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155586#p155586</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Возможно ли узнать выбранную папку закладки в chrome?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155585#p155585" />
			<content type="html"><![CDATA[<p>Вечер добрый.<br />Собственно, сабж.<br />Для примера прикладываю скриншот.<br />При добавлении закладки в хроме открывается миниокошко, в котором можно ввести название закладки и выбрать папку для сохранения (зеленая стрелка).<br />Возможно ли как то подцепиться и это название папки как то вытащить?<br />И получить в код строку, с примера, с &quot;gJ&quot;?<br />Или только скриншотить название нужной папки и делать какой-нибудь imagesearch?</p><p>PS Или как правильно запарсить файл default\bookmarks, чтобы добыть из него к какой папке принадлежит ссылка?</p>]]></content>
			<author>
				<name><![CDATA[Gh0sTG0]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39523</uri>
			</author>
			<updated>2022-11-10T19:32:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155585#p155585</id>
		</entry>
</feed>
