<?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=15091&amp;type=atom" />
	<updated>2024-02-29T09:49:55Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15091</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160439#p160439" />
			<content type="html"><![CDATA[<p>Спасибо. Про DevTools Protocol знаю, но для запуска браузера по умолчанию не очень подходит - тот запускается сам и без ключей.</p>]]></content>
			<author>
				<name><![CDATA[ant_serg57]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42480</uri>
			</author>
			<updated>2024-02-29T09:49:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160439#p160439</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160432#p160432" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>так как браузеры не предоставляют для этого никакого интерфейса</p></blockquote></div><p>Ну, не то, чтобы никакого, есть <a href="https://chromedevtools.github.io/devtools-protocol/">Chrome DevTools Protocol</a>, которым можно воспользоваться через <a href="https://github.com/G33kDude/Chrome.ahk">Chrome.ahk</a>. Для его использования браузер должен быть запущен с определёнными ключами.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-02-28T22:10:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160432#p160432</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160431#p160431" />
			<content type="html"><![CDATA[<p>Если задача находить DOM-элементы на странице и взаимодействовать с ними, то наилучший подход здесь — это какое-либо расширение для браузера, которое может по какому-нибудь событию (например, по горячей клавише) запускать на странице пользовательский джаваскрипт, который будет выполнять нужные действия и выводить наружу результаты. К примеру, есть расширение AutoControl, которое может такое делать. А AutoHotkey сам по себе имеет очень ограниченные возможности для решения подобных задач, так как браузеры не предоставляют для этого никакого интерфейса.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-02-28T21:56:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160431#p160431</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160430#p160430" />
			<content type="html"><![CDATA[<p>А есть какой-нибудь смотрельщик, чтобы показывало все элементы на текушей странице? Тогда бы легко можно было находить то что нужно.<br />Хм, может можно обертку к этим элементам сделать, чтобы они отображались в более привычном html-виде, пусть даже без возможности изменения, есть что-нибудь на эту тему?</p>]]></content>
			<author>
				<name><![CDATA[ant_serg57]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42480</uri>
			</author>
			<updated>2024-02-28T21:32:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160430#p160430</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160417#p160417" />
			<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>2024-02-26T20:31:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160417#p160417</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160416#p160416" />
			<content type="html"><![CDATA[<p>Жалко конечно. А видео ютуба на паузу так ставить и снимать с нее можно?</p>]]></content>
			<author>
				<name><![CDATA[ant_serg57]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42480</uri>
			</author>
			<updated>2024-02-26T20:00:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160416#p160416</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160365#p160365" />
			<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>2024-02-20T06:28:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160365#p160365</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160364#p160364" />
			<content type="html"><![CDATA[<p>Этот пример работает без отладочного режима браузера - есть ли возможность адаптировать его для получения содержимого страницы для работы с html-элементами?</p>]]></content>
			<author>
				<name><![CDATA[ant_serg57]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42480</uri>
			</author>
			<updated>2024-02-20T01:06:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160364#p160364</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136830#p136830" />
			<content type="html"><![CDATA[<p>Ого столько кода из-за одного клика на нужную кнопку... Большое спасибо и низкий вам поклон. Все работает. Я сам такой код точно не написал бы. Теперь я знаю куда можно обратиться с вопросами по скрипткодингу.</p>]]></content>
			<author>
				<name><![CDATA[Ventura_sv]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40513</uri>
			</author>
			<updated>2019-12-12T19:22:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136830#p136830</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136819#p136819" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Ventura_sv пишет:</cite><blockquote><p>Для этой страницы https://www.pathofexile.com/trade/searc … QLrPmWpCw. Страница сайта игры Path of exile. Справа цена за вещь, а снизу кнопка &quot;whisper&quot; она интересует. Результат поиска будет 1, т.е. первый.</p></blockquote></div><p>В личку не надо писать, если только не хотите оплатить работу.<br />У меня так сработало:<br /></p><div class="codebox"><pre><code>SetBatchLines, -1
Return

$F1::
   SendMessage, WM_GETOBJECT := 0x003D, 0, 1, Chrome_RenderWidgetHostHWND1, ahk_class Chrome_WidgetWin_1
   if !accChrome := AccObjectFromWindow( WinExist(&quot;ahk_class Chrome_WidgetWin_1&quot;) ) {
      MsgBox, Не удалось получить accessible-object
      ExitApp
   }
   if !AccElem := SearchElement(accChrome, {Role: ROLE_SYSTEM_PUSHBUTTON := 0x2B, Name: &quot;Whisper&quot;}) {
      MsgBox, Кнопка &quot;Whisper&quot; не найдена
      ExitApp
   }
   AccElem.accDoDefaultAction(0)
Return

SearchElement(parentElement, params)
{
   found := true
   for k, v in params {
      try (parentElement[&quot;acc&quot; . k](0) != v &amp;&amp; found := false)
      catch 
         found := false
   } until !found
   if found
      Return parentElement
   
   for k, v in AccChildren(parentElement)
      if obj := SearchElement(v, params)
         Return obj
}

AccObjectFromWindow(hWnd, idObject = 0)
{
   static IID_IDispatch   := &quot;{00020400-0000-0000-C000-000000000046}&quot;
        , IID_IAccessible := &quot;{618736E0-3C3D-11CF-810C-00AA00389B71}&quot;
        , OBJID_NATIVEOM  := 0xFFFFFFF0, VT_DISPATCH := 9, F_OWNVALUE := 1
        , h := DllCall(&quot;LoadLibrary&quot;, Str, &quot;oleacc&quot;, Ptr)
        
   VarSetCapacity(IID, 16), idObject &amp;= 0xFFFFFFFF
   DllCall(&quot;ole32\CLSIDFromString&quot;, Str, idObject = OBJID_NATIVEOM ? IID_IDispatch : IID_IAccessible, Ptr, &amp;IID)
   if DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, Ptr, hWnd, UInt, idObject, Ptr, &amp;IID, PtrP, pAcc) = 0
      Return ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
}

AccChildren(Acc) {
   static VT_DISPATCH := 9
   Loop 1  {
      if ComObjType(Acc, &quot;Name&quot;) != &quot;IAccessible&quot;  {
         error := &quot;Invalid IAccessible Object&quot;
         break
      }
      cChildren := Acc.accChildCount, Children := []
      VarSetCapacity(varChildren, cChildren*(8 + A_PtrSize*2), 0)
      res := DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Ptr&quot;, ComObjValue(Acc), &quot;Int&quot;, 0
                                                , &quot;Int&quot;, cChildren, &quot;Ptr&quot;, &amp;varChildren, &quot;IntP&quot;, cChildren)
      if (res != 0) {
         error := &quot;AccessibleChildren DllCall Failed&quot;
         break
      }
      Loop % cChildren  {
         i := (A_Index - 1)*(A_PtrSize*2 + 8)
         child := NumGet(varChildren, i + 8)
         Children.Push( (b := NumGet(varChildren, i) = VT_DISPATCH) ? AccQuery(child) : child )
         ( b &amp;&amp; ObjRelease(child) )
      }
   }
   if error
      ErrorLevel := error
   else
      Return Children.MaxIndex() ? Children : &quot;&quot;
}

AccQuery(Acc)  {
   static IAccessible := &quot;{618736e0-3c3d-11cf-810c-00aa00389b71}&quot;, VT_DISPATCH := 9, F_OWNVALUE := 1
   try Return ComObject(VT_DISPATCH, ComObjQuery(Acc, IAccessible), F_OWNVALUE)
}</code></pre></div><p>По нажатию F1 ищет, если нашлась — нажимает.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-12-11T23:16:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136819#p136819</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136817#p136817" />
			<content type="html"><![CDATA[<p>Для обоих сложно, AHK нативно не поддерживает ни тот, ни другой, прямой доступ к странице есть только для Internet Explorer. Однако иногда можно воспользоваться некоторыми косвенными способами взаимодействия, нужно видеть страницу, чтобы сказать наверняка.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-12-11T22:21:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136817#p136817</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136812#p136812" />
			<content type="html"><![CDATA[<p>В основном пользуюсь google chrome. Но если вам легче будет мне помочь написать код для firefox, ничего страшного. Мне главное результат.</p>]]></content>
			<author>
				<name><![CDATA[Ventura_sv]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40513</uri>
			</author>
			<updated>2019-12-11T19:34:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136812#p136812</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136802#p136802" />
			<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>2019-12-11T15:18:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136802#p136802</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Поиск текста кнопки на сайте и нажатие на нее лкм]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136797#p136797" />
			<content type="html"><![CDATA[<p>Добрый день. Сразу извиняюсь, если такой вопрос уже подымался. Но конкретно найти именно в моем случае я не нашел. В Autohotkey понимаю слабо. Помогите написать код пжта. Итак задача: Необходимо найти на сайте кнопку с текстом (кнопка иногда находится в другом положении) и нажать на нее ЛКМ.<br />Допустим я могу средствами ahk найти этот текст кнопки через ctrl+F а как нажать на нее?</p>]]></content>
			<author>
				<name><![CDATA[Ventura_sv]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40513</uri>
			</author>
			<updated>2019-12-11T10:55:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136797#p136797</id>
		</entry>
</feed>
