Is there a way to search for text on a webpage and move the mouse cursor to that position?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Is there a way to search for text on a webpage and move the mouse cursor to that position?

Post by AHKStudent » 06 May 2021, 11:15

I did not follow this whole thread but on my machine the html only has a object with the data for me this works and obviously the regex could be improved. Press r to run.

Code: Select all

r::
	BingHtml := URLDownloadToVar("https://bing.com")
    RegexMatch(BingHtml, "s)""Description"":""(.+?)""", match)
    MsgBox, % clipboard := match1
ExitApp

URLDownloadToVar(url){
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.Open("GET",url)
	hObject.Send()
	return hObject.ResponseText
}

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Is there a way to search for text on a webpage and move the mouse cursor to that position?

Post by boiler » 06 May 2021, 11:44

The problem with that approach (taking the text off the main Bing page), as discussed earlier, is that on days when the explanation has multiple paragraphs, the only place to get all of it is to follow the “Learn More” link. The full text isn’t in the main page on those days, only the first paragraph.

kairushinjuu
Posts: 46
Joined: 07 May 2020, 07:02

Re: Is there a way to search for text on a webpage and move the mouse cursor to that position?

Post by kairushinjuu » 07 May 2021, 22:22

how about something like this?

Code: Select all

URL_ := "https://www.bing.com/"

	WB := ComObjCreate("InternetExplorer.Application")
	WB.Visible := False
    WB.Navigate(URL_)
	   While WB.readyState != 4 || WB.document.readyState != "complete" || WB.busy
	   Sleep, 10
    WB.document.getElementsByClassName("learn_more")[0].click()
		While WB.readyState != 4 || WB.document.readyState != "complete" || WB.busy
	    Sleep, 10
	 Info := WB.document.getElementsByClassName("ency_imgTitle")[0].InnerText "`r`r" WB.document.getElementsByClassName("ency_desc")[0].InnerText ; Save info to a variable
	WB.Quit()
	
Msgbox % Info


Post Reply

Return to “Ask for Help (v1)”