Using find on page to click or wait for text elements on a website.

Post your working scripts, libraries and tools
leosouza85
Posts: 44
Joined: 22 Jul 2016, 16:28

Using find on page to click or wait for text elements on a website.

22 Jul 2020, 13:34

I developed this workflow to click elements on a website (chrome, but maybe can be ported to other browsers)

First of all you have to press a control+f on your chrome window and search for a word present on a website.

Image

Then print screen, paste on paint, cut a rectangle about 10x1 pixels of the color orange (you can fine tune this part) from the word highlighted and save this little rectangle as orange.png

Image


This script, when you press control + 1, will click on the first word "notifications" that appear on a site. to click other word or text element just change the third line to the desired string

Code: Select all

^1:: 
send, ^f
send, notifications
loop
ImageSearch, Foundx, Foundy, 0, 0, A_screenwidth, A_screenheight, *1, orange.png
until ErrorLevel = 0
sleep 100
click, %Foundx%, %Foundy% ; if you are wanting to just wait for the element, dont put this line
return
Sorry about my English, it is not my native language.

Advantages over classic imagesearch:
resolution independent
font independent
autoscroll to the first found element
can be ported to any software with find function that highlights the found string
No need to learn com object or complex code
can be used to wait for a text element to appear

you can also do an offset to click something that is not a text:

Code: Select all

^1:: 
send, ^f
send, notifications
loop
ImageSearch, Foundx, Foundy, 0, 0, A_screenwidth, A_screenheight, *1, orange.png
until ErrorLevel = 0
sleep 100
Foundx := Foundx + 100 ; a 100 pixel offset to the right
Foundy := Foundy + 100 ; a 100 pixel down offset 
click, %Foundx%, %Foundy% ; if you are wanting to just wait for the element, dont put this line
return

Return to “Scripts and Functions”

Who is online

Users browsing this forum: DataLife and 18 guests