<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Получение элемента из <a href => из IE]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=13404</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13404&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Получение элемента из <a href => из IE».]]></description>
		<lastBuildDate>Fri, 16 Mar 2018 11:46:11 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124088#p124088</link>
			<description><![CDATA[<p><strong>KusochekDobra</strong><br />Спасибо, опробую и ваш вариант.<br />p.s. я опоздал на 35 секунд )</p>]]></description>
			<author><![CDATA[null@example.com (estenha)]]></author>
			<pubDate>Fri, 16 Mar 2018 11:46:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124088#p124088</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124087#p124087</link>
			<description><![CDATA[<div class="quotebox"><cite>estenha пишет:</cite><blockquote><p>Доброго времени суток! Вы не могли бы подсказать на примере вашего кода, который замечательно работает, как реализовать несколько иную задачу...</p></blockquote></div><p>Сделал через <strong><a href="https://autohotkey.com/docs/commands/IfInString.htm">IfInString</a> и Array.Push</strong> (мне к тому же еще нужен именно последний элемент из списка идентичных ссылок.) Если кому интересно:</p><div class="codebox"><pre><code>Larray := []
Needle = hyper-universe-
oIE := ComObjCreate(&quot;InternetExplorer.Application&quot;)
oIE.visible := True
oIE.navigate(&quot;https://www.mmorpg.com/sweepstakes&quot;)
While oIE.busy  
   Sleep, 20
links := oIE.document.links
; MsgBox % links.length
Loop % links.length  {
   link := links[A_Index - 1]
   b := link.href
   IfInString, b, %Needle%
	{
;	  MsgBox, % link.href
	  Larray.Push(link.href)
	}
}
z := Larray.MaxIndex()
MsgBox % &quot;Последний элемент &quot; Larray[z]

; for index, element in Larray ; здесь можно посмотреть, что в массиве
;	{
;		MsgBox % &quot;Element number &quot; . index . &quot; is &quot; . element
;	}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (estenha)]]></author>
			<pubDate>Fri, 16 Mar 2018 11:40:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124087#p124087</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124086#p124086</link>
			<description><![CDATA[<p>По условию, отображаемый текст ссылки должен быть эквивалентен &quot;Hyper Universe&quot; без учёта регистра. Если нужны все ссылки, отображаемый текст которых содержит &quot;Hyper Universe&quot;, можно записать так:<br /></p><div class="codebox"><pre><code>
oIE := ComObjCreate(&quot;InternetExplorer.Application&quot;)
oIE.visible := True
oIE.navigate(&quot;https://www.mmorpg.com/sweepstakes&quot;)
While oIE.busy  
	Sleep, 20
links := oIE.document.links
Loop % links.length  {
	link := links[A_Index - 1]
	if (CheckString(link.innerText, &quot;Hyper Universe&quot;))
		MsgBox, % link.href
}
ExitApp
CheckString(mainStr, srchStr) {
	if mainStr contains %srchStr%
		return true
	return false
}
</code></pre></div><p>Если нужны ссылки только из заголовков к каждой игре, то можно сделать выборку по классу и потом проходить циклом по её результату:<br /></p><div class="codebox"><pre><code>
oIE := ComObjCreate(&quot;InternetExplorer.Application&quot;)
oIE.visible := True
oIE.navigate(&quot;https://www.mmorpg.com/sweepstakes&quot;)
While oIE.busy  
	Sleep, 20
links := oIE.document.querySelectorAll(&quot;.suhlink&quot;)
Loop % links.length  {
	link := links[A_Index - 1]
	if (CheckString(link.innerText, &quot;Hyper Universe&quot;))
		MsgBox, % link.href
}
ExitApp
CheckString(mainStr, srchStr) {
	if mainStr contains %srchStr%
		return true
	return false
}
</code></pre></div><p>Если необходимо искать вхождения &quot;hyper-universe&quot; в тексте ссылки, замените условие:<br /></p><div class="codebox"><pre><code>
if (CheckString(link.innerText, &quot;Hyper Universe&quot;))
</code></pre></div><p>На:<br /></p><div class="codebox"><pre><code>
if (CheckString(link.href, &quot;hyper-universe&quot;))
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Fri, 16 Mar 2018 11:40:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124086#p124086</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124080#p124080</link>
			<description><![CDATA[<p>Доброго времени суток! Вы не могли бы подсказать на примере вашего кода, который замечательно работает, как реализовать несколько иную задачу - необходимо на основе подстроки из link.href выбирать определенные ссылки, т.е. в данном вашем коде и примере с сайта нужно находить, возьмем тот же Hyper Universe, в атрибуте href=&quot;/sweepstakes/hyper-universe-mvp-starter-pack-sweepstakes-1000000057&quot; подстроку hyper-universe, и выводить полную ссылку с этой подстрокой в тот же MsgBox. Я пробовал использовать <strong>if Var contains MatchList</strong> - <strong>if link.href contains hyper-universe</strong>, но в этом случае выводятся все ссылки подряд. Видимо, по неопытности я чего-то еще не понимаю.</p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>У меня работает:<br /></p><div class="codebox"><pre><code>oIE := ComObjCreate(&quot;InternetExplorer.Application&quot;)
oIE.visible := True
oIE.navigate(&quot;https://www.mmorpg.com/sweepstakes&quot;)
While oIE.busy  
   Sleep, 20
links := oIE.document.links
Loop % links.length  {
   link := links[A_Index - 1]
   if (link.innerText = &quot;Hyper Universe&quot;)
      MsgBox, % link.href
}</code></pre></div></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (estenha)]]></author>
			<pubDate>Fri, 16 Mar 2018 03:05:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124080#p124080</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124073#p124073</link>
			<description><![CDATA[<p><strong>KusochekDobra</strong><br />Спасибо. Все работает хорошо.</p>]]></description>
			<author><![CDATA[null@example.com (romzes96)]]></author>
			<pubDate>Thu, 15 Mar 2018 17:56:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124073#p124073</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124044#p124044</link>
			<description><![CDATA[<p>Замените в примере, строку:<br /></p><div class="codebox"><pre><code>MsgBox, % href ? href : &quot;Не найдено&quot;</code></pre></div><p>На:<br /></p><div class="codebox"><pre><code>
if (href)
	activlink := href
else
	MsgBox, Не найдено.
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Wed, 14 Mar 2018 10:49:25 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124044#p124044</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=124043#p124043</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Тогда так примерно:<br /></p><div class="codebox"><pre><code>linkText := &quot;Dsaasd&quot;

oIE := WBGet()
if !IsObject(oIE)  {
   MsgBox, Не удалось получить объект InternetExplorer
   return
}
links := oIE.document.links, href := &quot;&quot;
Loop % links.length  {
   link := links[A_Index - 1]
   if (link.innerText = linkText &amp;&amp; href := link.href)
      break
}
MsgBox, % href ? href : &quot;Не найдено&quot;

WBGet(WinTitle := &quot;ahk_class IEFrame&quot;, Svr# := 1)
{
   static msg := DllCall(&quot;RegisterWindowMessage&quot;, Str, &quot;WM_HTML_GETOBJECT&quot;)
        , IID_IWebBrowserApp := &quot;{0002DF05-0000-0000-C000-000000000046}&quot;
        , IID_IHTMLDocument2 := &quot;{332C4425-26CB-11D0-B483-00C04FD90119}&quot;
        , VT_DISPATCH := 9, F_OWNVALUE := 1
        
   SendMessage, msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
   lResult := ErrorLevel
   if (lResult = &quot;FAIL&quot;)
      return
   
   VarSetCapacity(GUID, 16, 0)
   DllCall(&quot;ole32\CLSIDFromString&quot;, WStr, IID_IHTMLDocument2, Ptr, &amp;GUID)
   DllCall(&quot;oleacc\ObjectFromLresult&quot;, Ptr, lResult, Ptr, &amp;GUID, Ptr, 0, PtrP, pdoc)
   oWb := ComObject(VT_DISPATCH, ComObjQuery(pdoc, IID_IWebBrowserApp, IID_IWebBrowserApp), F_OWNVALUE)
   ObjRelease(pdoc)
   return oWb
}</code></pre></div></blockquote></div><p>Здравствуйте. Воспользовался Вашим кодом. для моих целей работает превосходно. Но не могу понять как сделать так что бы в конце не выпрыгивало окно с ссылкой. не могли бы Вы помочь разобраться? Хотелось бы что бы ссылка просто записывалась в переменную допустим <strong>activlink</strong>. Но что бы не было этого окна по завершению скрипта. Но что бы осталось окно о том что ссылка не найдена.</p>]]></description>
			<author><![CDATA[null@example.com (romzes96)]]></author>
			<pubDate>Wed, 14 Mar 2018 09:39:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=124043#p124043</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123419#p123419</link>
			<description><![CDATA[<div class="codebox"><pre><code>document.getElementsByClassName(&quot;contestopen&quot;)[0].getElementsByTagName(&quot;a&quot;)[0].href</code></pre></div><p>Также можно через QuerySelectorAll либо XPath, почитайте информацию сами если заинтересует.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Fri, 26 Jan 2018 20:31:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123419#p123419</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123418#p123418</link>
			<description><![CDATA[<p><strong>Malcev</strong>, при вводе этого:<br /></p><div class="codebox"><pre><code>document.getElementsByClassName(&quot;contestopen&quot;)[0].cells[1].links</code></pre></div><p>выводит undefined</p>]]></description>
			<author><![CDATA[null@example.com (Alex_Lexon)]]></author>
			<pubDate>Fri, 26 Jan 2018 20:01:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123418#p123418</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123413#p123413</link>
			<description><![CDATA[<p>А в чем проблема? Приведите код.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Fri, 26 Jan 2018 19:12:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123413#p123413</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123410#p123410</link>
			<description><![CDATA[<p><strong>Malcev</strong>, да, этот код действительно работает! Спасибо.<br />А если мне нужно вывести ссылки из getElementsByClassName, то тогда как? Ибо если пробую после класса ставить .links, то выдаёт - undefined.</p>]]></description>
			<author><![CDATA[null@example.com (Alex_Lexon)]]></author>
			<pubDate>Fri, 26 Jan 2018 18:33:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123410#p123410</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123406#p123406</link>
			<description><![CDATA[<p>У меня работает:<br /></p><div class="codebox"><pre><code>oIE := ComObjCreate(&quot;InternetExplorer.Application&quot;)
oIE.visible := True
oIE.navigate(&quot;https://www.mmorpg.com/sweepstakes&quot;)
While oIE.busy  
   Sleep, 20
links := oIE.document.links
Loop % links.length  {
   link := links[A_Index - 1]
   if (link.innerText = &quot;Hyper Universe&quot;)
      MsgBox, % link.href
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Fri, 26 Jan 2018 17:39:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123406#p123406</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123392#p123392</link>
			<description><![CDATA[<p>Не работает данный способ, возможно, Вы не совсем поняли, про какие ссылки я говорю.</p>]]></description>
			<author><![CDATA[null@example.com (Alex_Lexon)]]></author>
			<pubDate>Fri, 26 Jan 2018 14:28:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123392#p123392</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123384#p123384</link>
			<description><![CDATA[<p>Ссылки находятся во фрейме:<br /></p><div class="codebox"><pre><code>oIE := ComObjCreate(&quot;InternetExplorer.Application&quot;)
oIE.visible := True
oIE.navigate(&quot;https://www.mmorpg.com/sweepstakes&quot;)
While oIE.busy  
   Sleep, 20
links := oIE.document.parentWindow.frames[6].document.links
Loop % links.length  {
   link := links[A_Index - 1]
   MsgBox, % &quot;Link text: &quot; . link.innerText . &quot;`nLink href: &quot; . link.href
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Thu, 25 Jan 2018 22:31:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123384#p123384</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получение элемента из <a href => из IE]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=123381#p123381</link>
			<description><![CDATA[<p>https://www.mmorpg.com/sweepstakes<br />Ссылки на игры, что находятся в классе &quot;contestopen&quot;. Справа от описания есть названия игр, что являются ссылками, ссылки на игры из класса &quot;contestopen&quot; и нужны.</p>]]></description>
			<author><![CDATA[null@example.com (Alex_Lexon)]]></author>
			<pubDate>Thu, 25 Jan 2018 20:57:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=123381#p123381</guid>
		</item>
	</channel>
</rss>
