<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Получить ссылку из неактивного окна браузера]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11998&amp;type=atom" />
	<updated>2017-02-04T03:09:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11998</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111837#p111837" />
			<content type="html"><![CDATA[<p>Оказалось, мешала строка в моём коде:</p><div class="codebox"><pre><code>DetectHiddenWindows, on</code></pre></div><p>Перед действием её можно отключать (off), а потом включать.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2017-02-04T03:09:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111837#p111837</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111082#p111082" />
			<content type="html"><![CDATA[<p>Не могу понять, по какой причине приведенный ниже код отдельно работает, но если запускать из моего постоянного скрипта, со множеством меток, по горячей клавише выводит пустое окно? —<br /></p><div class="codebox"><pre><code>
f6::
	;nTime := A_TickCount
	WinGetClass, sClass, A
	URL := GetBrowserURL(sClass)
	MsgBox, % URL
Return


GetBrowserURL(sClass) {
	Static AccBrowsersClass := &quot;MozillaWindowClass,Chrome_WidgetWin_0,Chrome_WidgetWin_1,Maxthon3Cls_MainFrm,Slimjet_WidgetWin_1&quot;
	Static DDEBrowsersClass := &quot;MozillaWindowClass,IEFrame,OperaWindowClass&quot;
	If sClass In % AccBrowsersClass
		Return GetBrowserURL_ACC(sClass)
	Else If sClass In % DDEBrowsersClass
		Return GetBrowserURL_DDE(sClass)
}
GetBrowserURL_DDE(sClass) {
	WinGet, sServer, ProcessName, % &quot;ahk_class &quot; sClass
	StringTrimRight, sServer, sServer, 4
	iCodePage := A_IsUnicode ? 0x04B0 : 0x03EC ; 0x04B0 = CP_WINUNICODE, 0x03EC = CP_WINANSI
	DllCall(&quot;DdeInitialize&quot;, &quot;UPtrP&quot;, idInst, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
	hServer := DllCall(&quot;DdeCreateStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;Str&quot;, sServer, &quot;int&quot;, iCodePage)
	hTopic := DllCall(&quot;DdeCreateStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;Str&quot;, &quot;WWW_GetWindowInfo&quot;, &quot;int&quot;, iCodePage)
	hItem := DllCall(&quot;DdeCreateStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;Str&quot;, &quot;0xFFFFFFFF&quot;, &quot;int&quot;, iCodePage)
	hConv := DllCall(&quot;DdeConnect&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hServer, &quot;UPtr&quot;, hTopic, &quot;Uint&quot;, 0)
	hData := DllCall(&quot;DdeClientTransaction&quot;, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;UPtr&quot;, hConv, &quot;UPtr&quot;, hItem, &quot;UInt&quot;, 1, &quot;Uint&quot;, 0x20B0, &quot;Uint&quot;, 10000, &quot;UPtrP&quot;, nResult) ; 0x20B0 = XTYP_REQUEST, 10000 = 10s timeout
	sData := DllCall(&quot;DdeAccessData&quot;, &quot;Uint&quot;, hData, &quot;Uint&quot;, 0, &quot;Str&quot;)
	DllCall(&quot;DdeFreeStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hServer)
	DllCall(&quot;DdeFreeStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hTopic)
	DllCall(&quot;DdeFreeStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hItem)
	DllCall(&quot;DdeUnaccessData&quot;, &quot;UPtr&quot;, hData)
	DllCall(&quot;DdeFreeDataHandle&quot;, &quot;UPtr&quot;, hData)
	DllCall(&quot;DdeDisconnect&quot;, &quot;UPtr&quot;, hConv)
	DllCall(&quot;DdeUninitialize&quot;, &quot;UPtr&quot;, idInst)
	csvWindowInfo := StrGet(&amp;sData, &quot;CP0&quot;)
	StringSplit, sWindowInfo, csvWindowInfo, `&quot; ;&quot;; comment to avoid a syntax highlighting issue in autohotkey.com/boards
	Return sWindowInfo2
}
GetBrowserURL_ACC(sClass) {
	static nWindow, accAddressBar
	If (nWindow != WinExist(&quot;ahk_class &quot; sClass)) ; reuses accAddressBar if it&#039;s the same window
	{
		nWindow := WinExist(&quot;ahk_class &quot; sClass)
		accAddressBar := GetAddressBar(Acc_ObjectFromWindow(nWindow))
	}
	Try sURL := accAddressBar.accValue(0)
	If (sURL == &quot;&quot;) {
		WinGet, nWindows, List, % &quot;ahk_class &quot; sClass ; In case of a nested browser window as in the old CoolNovo (TO DO: check if still needed)
		If (nWindows &gt; 1) {
			accAddressBar := GetAddressBar(Acc_ObjectFromWindow(nWindows2))
			Try sURL := accAddressBar.accValue(0)
		}
	}
	If (sURL == &quot;&quot;)
		nWindow := -1 ; Don&#039;t remember the window if there is no URL
	Return sURL
}
GetAddressBar(accObj, accPath:=&quot;&quot;) {
	; static a:=0
	; ToolTip % a++ ; 360 for firefox, 47 for modern Opera
	n := 0
	Try If ((accObj.accRole(0) == 42) and accObj.accValue(0))
		Return accObj
	For nChild, accChild in Acc_Children(accObj) {
		n++
		currentPath := accPath n &quot;.&quot;
		;ToolTip % currentPath
		If IsObject(accAddressBar := GetAddressBar(accChild, currentPath)) {
			Return accAddressBar
		}
	}
}
;~LButton::ToolTip

Acc_Init() {
	static h
	If Not h
		h:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;oleacc&quot;,&quot;Ptr&quot;)
}
Acc_ObjectFromWindow(hWnd, idObject = 0) {
	Acc_Init()
	If DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, &quot;Ptr&quot;, hWnd, &quot;UInt&quot;, idObject&amp;=0xFFFFFFFF, &quot;Ptr&quot;, -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,&quot;Int64&quot;),&quot;Int64&quot;), &quot;Ptr*&quot;, pacc)=0
	Return ComObjEnwrap(9,pacc,1)
}
Acc_Query(Acc) {
	Try Return ComObj(9, ComObjQuery(Acc,&quot;{618736e0-3c3d-11cf-810c-00aa00389b71}&quot;), 1)
}
Acc_Children(Acc) {
	If ComObjType(Acc,&quot;Name&quot;) != &quot;IAccessible&quot;
		ErrorLevel := &quot;Invalid IAccessible Object&quot;
	Else {
		Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
		If DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;,ComObjValue(Acc), &quot;Int&quot;,0, &quot;Int&quot;,cChildren, &quot;Ptr&quot;,VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&amp;varChildren, &quot;Int*&quot;,cChildren)=0 {
			Loop %cChildren%
				i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
			Return Children.MaxIndex()?Children:
		} Else
			ErrorLevel := &quot;AccessibleChildren DllCall Failed&quot;
	}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2017-01-15T13:24:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111082#p111082</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111051#p111051" />
			<content type="html"><![CDATA[<p>Потому что:<br /></p><div class="quotebox"><blockquote><p>На Blink не работает, как и на всех прочих хромоногах.</p></blockquote></div><p>Используйте полный вариант библиотеки по ссылке с 5 поста.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-15T04:49:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111051#p111051</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111049#p111049" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><div class="codebox"><pre><code>f11::
msgbox % GetBrowserURL_DDE(&quot;MozillaWindowClass&quot;)
...</code></pre></div></blockquote></div><p>Почему, когда запущено две Оперы, с классами &quot;Chrome_WidgetWin_1&quot; и &quot;OperaWindowClass&quot;, при активном первом окне — выводится URL второго?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2017-01-15T01:21:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111049#p111049</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107540#p107540" />
			<content type="html"><![CDATA[<p><strong>stealzy</strong>, какое именно окно?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-12T09:39:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107540#p107540</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107488#p107488" />
			<content type="html"><![CDATA[<p>А, понял, у меня просто был ещё почтовый клиент thunderbird в это время открыт, он имеет тот же класс.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-11T18:05:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107488#p107488</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107487#p107487" />
			<content type="html"><![CDATA[<p>Странно. У меня на нескольких компьютерах FF 48.0.2 на win7 работает.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-09-11T17:57:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107487#p107487</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107484#p107484" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, у меня, когда окно FF свёрнуто, скрипт, который ты привёл, выдает пустую строку.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-11T17:45:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107484#p107484</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107482#p107482" />
			<content type="html"><![CDATA[<p>Круто, спасибо!</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2016-09-11T15:47:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107482#p107482</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107480#p107480" />
			<content type="html"><![CDATA[<p>Мы ведь не про Opera Presto говорим? На Blink не работает, как и на всех прочих хромоногах.<br />По поводу firefox&#039;a - я сам удивился, т.к. в прошлой версии (а она у меня сохранилась :-) он использовал DDE.<br />Почитав ветку, узнал, что последний firefox nightly dde уже вроде не поддерживает.</p><p>Медленно происходит только первый поиск контрола. Потому что сейчас ищется по всем контролам браузера (для firefox он проходит 360 контролов у меня). Со второго раза он быстрее DDE.<br />Я предложил использовать предустановленные пути для старта поиска контролов в <a href="https://autohotkey.com/boards/viewtopic.php?f=6&amp;t=3702&amp;p=109556#p109556">ветке библиотеки</a>, подожду отзывов у какого какие пути - может совсем разные у всех.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2016-09-11T12:50:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107480#p107480</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107479#p107479" />
			<content type="html"><![CDATA[<p>Для оперы также должно работать, только класс оперы надо поставить.<br />Свой код я вырезал из той же универсальной библиотеки, только непонятно зачем автор скрипта с фаерфоксом использует ACC, когда через DDE быстрее.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-09-11T12:31:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107479#p107479</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107475#p107475" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, а для Оперы и остальных браузеров на Blink?<br />Дабы не изобретать заново изобретенное, рекомендую универсальную библиотеку для всех браузеров:<br /><a href="https://translate.google.com/#ru/en/получить%20содержимое%20адресной%20строки%20браузера">https://translate.google.com/#ru/en/пол … и браузера</a>.<br /><a href="http://ru.lmgtfy.com/?q=get+the+contents+of+the+browser&#039;s+address+bar+autohotkey">http://ru.lmgtfy.com/?q=get+the+content … autohotkey</a>.<br />Если хотим из неактивного окна, заменяем &quot;A&quot; в командах на идентификатор окна браузера.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2016-09-11T04:34:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107475#p107475</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107474#p107474" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>f11::
msgbox % GetBrowserURL_DDE(&quot;MozillaWindowClass&quot;)

GetBrowserURL_DDE(sClass) {
	WinGet, sServer, ProcessName, % &quot;ahk_class &quot; sClass
	StringTrimRight, sServer, sServer, 4
	iCodePage := A_IsUnicode ? 0x04B0 : 0x03EC ; 0x04B0 = CP_WINUNICODE, 0x03EC = CP_WINANSI
	DllCall(&quot;DdeInitialize&quot;, &quot;UPtrP&quot;, idInst, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
	hServer := DllCall(&quot;DdeCreateStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;Str&quot;, sServer, &quot;int&quot;, iCodePage)
	hTopic := DllCall(&quot;DdeCreateStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;Str&quot;, &quot;WWW_GetWindowInfo&quot;, &quot;int&quot;, iCodePage)
	hItem := DllCall(&quot;DdeCreateStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;Str&quot;, &quot;0xFFFFFFFF&quot;, &quot;int&quot;, iCodePage)
	hConv := DllCall(&quot;DdeConnect&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hServer, &quot;UPtr&quot;, hTopic, &quot;Uint&quot;, 0)
	hData := DllCall(&quot;DdeClientTransaction&quot;, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;UPtr&quot;, hConv, &quot;UPtr&quot;, hItem, &quot;UInt&quot;, 1, &quot;Uint&quot;, 0x20B0, &quot;Uint&quot;, 10000, &quot;UPtrP&quot;, nResult) ; 0x20B0 = XTYP_REQUEST, 10000 = 10s timeout
	sData := DllCall(&quot;DdeAccessData&quot;, &quot;Uint&quot;, hData, &quot;Uint&quot;, 0, &quot;Str&quot;)
	DllCall(&quot;DdeFreeStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hServer)
	DllCall(&quot;DdeFreeStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hTopic)
	DllCall(&quot;DdeFreeStringHandle&quot;, &quot;UPtr&quot;, idInst, &quot;UPtr&quot;, hItem)
	DllCall(&quot;DdeUnaccessData&quot;, &quot;UPtr&quot;, hData)
	DllCall(&quot;DdeFreeDataHandle&quot;, &quot;UPtr&quot;, hData)
	DllCall(&quot;DdeDisconnect&quot;, &quot;UPtr&quot;, hConv)
	DllCall(&quot;DdeUninitialize&quot;, &quot;UPtr&quot;, idInst)
	csvWindowInfo := StrGet(&amp;sData, &quot;CP0&quot;)
	StringSplit, sWindowInfo, csvWindowInfo, `&quot; ;&quot;; comment to avoid a syntax highlighting issue in autohotkey.com/boards
	Return sWindowInfo2
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2016-09-11T03:01:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107474#p107474</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Получить ссылку из неактивного окна браузера]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107473#p107473" />
			<content type="html"><![CDATA[<p>Можно ли получить содержимое адресной строки (ссылку) из свернутого или неактивного окна Мозиллы или Оперы?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2016-09-10T22:18:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107473#p107473</id>
		</entry>
</feed>
