Find and click text in web page (revisited)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jleslie48
Posts: 5
Joined: 28 Nov 2016, 13:45

Find and click text in web page (revisited)

24 Jul 2017, 09:05

I found this old thread and it basically works

https://autohotkey.com/board/topic/1028 ... -web-page/

it actually does what its supposed to, it finds the text on a webpage and clicks it. the only issue is after it
does what its supposed to it pops up an error message 0x80070005 - Access is denied.
Here is a screen shot capture:
findtext_Image1.jpg
findtext_Image1.jpg (288.96 KiB) Viewed 1166 times
On further inspection, this only happens on bbc.com, on yahoo.com or msn.com there is no error.

Here is my program:


Code: Select all


#SingleInstance Force

Gui, +Alwaysontop
Gui, Add, text , , Enter search term:
Gui, Add, edit, x+5 ym w200 vsearchterm, 
Gui, Add, Button, x+5 ym gsearch default, SEARCH

Gui, show
return

search:
Gui, Submit, NoHide
wb := WBGet()
Links := wb.Document.Links
		Loop % Links.Length
	If InStr(Links[A_Index-1].InnerText, searchterm)
		Links[A_Index-1].Click()
return



WBGet(WinTitle="ahk_class IEFrame", Svr#=1) { ; based on ComObjQuery docs
   static   msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
   ,   IID := "{0002DF05-0000-0000-C000-000000000046}" ; IID_IWebBrowserApp
;   ,   IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IID_IHTMLWindow2
   SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
   if (ErrorLevel != "FAIL") {
      lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
      if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
         DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
         return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
      }
   }
} ; by Jethrow



esc::exitApp

Any suggestions?

This works with the IE explorer, Not sure about any others.
User avatar
tank
Posts: 3122
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: Find and click text in web page (revisited)

24 Jul 2017, 12:07

Code: Select all

If InStr(Links[A_Index-1].InnerText, searchterm)
{
Links[A_Index-1].Click()
break
}
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Spawnova and 276 guests