Clicking on a text or link in google Chrome SIMPLE TUTORIAL (no COM or IMGSEARCH required)

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

Clicking on a text or link in google Chrome SIMPLE TUTORIAL (no COM or IMGSEARCH required)

28 Dec 2020, 23:53

Hi there,

I want to share a simple technique that I developed so we can click on a text, wait for a text to load etc.

With chrome open on the site that you want:

Code: Select all

send, ^f ;this will open the the find dialog

send, the word or phrase that you want to search ;this will fill the find dialog and wil highlight the found word

send, ^{Enter} ; this will click the highlighted word

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;How to click in a text only when it is loaded:

loop

{
sleep 1000 ; add some sleep so the browser don't go crazy
send, ^f ;this will open the the find dialog

text := the word or phrase

send, %text% ;this will fill the find dialog and wil highlight or not the found word

send, {ESC} ;if the word is not found, nothing happens, if word found it will be highlighted

send, ^c

if (clipboard = text){

send, {Enter} ; this will click the text when found, when not in dialog you want to press enter, not control enter so you open the link in the same tab
break ;this will stop the loop when the text is found

}

}
I'm writing the code from memory so maybe some syntax are wrong, also english is not my first language.
leosouza85
Posts: 44
Joined: 22 Jul 2016, 16:28

Re: Clicking on a text or link in google Chrome SIMPLE TUTORIAL (no COM or IMGSEARCH required)

30 Dec 2020, 22:55

@Joe Glines I want your opinion on that technique, since you are the great master of AHK

I also found a way to click the image that you are looking for.

when the element is focused, via doing the send {tabs}

Code: Select all

send {appskey} ; this will open the context menu
send o ; this will copy the image address to the clipboard. Some websites dont give this option but you can send e, after the send {appskey} to copy the link address to the clipboard.
clipwait, 1 ; this will wait with the timeout of 1 second the clipboard have data (because maybe the script is faster than clipboard can copy the data)
Then you could test with if, if the image is the image that you want and then send {enter}

Also I suspect that the characters after the send {appskey} are language dependent, my google chrome is in portuguese, so maybe in english chrome you should send another character.
User avatar
Joe Glines
Posts: 714
Joined: 30 Sep 2013, 20:49
Facebook: https://www.facebook.com/theAutomatorGuru/
Google: https://plus.google.com/105328929654286634910
GitHub: joetazz
Location: Dallas
Contact:

Re: Clicking on a text or link in google Chrome SIMPLE TUTORIAL (no COM or IMGSEARCH required)

03 Jan 2021, 11:07

@leosouza85 Personally I'd never take this kind of approach. Given, with GeekDude's Chrome class, we can automate Chrome, I would (almost always) take that route. If I wasn't going that route I'd probably just use Automate my Task to create a quick (adhoc) temporarly solution

Find & Click AutoHotkey syntax writer Automate my Task :clap:
AHK Tutorials:Web Scraping | AHK Studio | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey :ugeek:
Connect with me on LinkedIn :beer: | YouTube
How-to: Create a shortcut that automatically
logs in to any website

:thumbup: Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Help support the AutoHotkey foundation
leosouza85
Posts: 44
Joined: 22 Jul 2016, 16:28

Re: Clicking on a text or link in google Chrome SIMPLE TUTORIAL (no COM or IMGSEARCH required)

03 Jan 2021, 14:39

Joe Glines wrote:
03 Jan 2021, 11:07
@leosouza85 Personally I'd never take this kind of approach. Given, with GeekDude's Chrome class, we can automate Chrome, I would (almost always) take that route. If I wasn't going that route I'd probably just use Automate my Task to create a quick (adhoc) temporarly solution
Hi Joe thank you for your answer! I know, it is a very simplistic approach. On my personal projects I use COM, Chrome Class and other things, but I'm trying to find the simplest and still reliable way to interact to Chrome, so people can automate with less effort/knowledge.

Maybe that approach is not as perfect as COM or Chrome Class, but is better than image search, since is not limited to screen scrolling, zoom, font and other small changes.

I'm using that approach to teach auto hot key to complete beginners at my work. I work on a government institution with 5.000 workers, and already have 20 students, and there are more people waiting to join.

Thank you so much for all your work! I'm Your fan.
User avatar
Joe Glines
Posts: 714
Joined: 30 Sep 2013, 20:49
Facebook: https://www.facebook.com/theAutomatorGuru/
Google: https://plus.google.com/105328929654286634910
GitHub: joetazz
Location: Dallas
Contact:

Re: Clicking on a text or link in google Chrome SIMPLE TUTORIAL (no COM or IMGSEARCH required)

03 Jan 2021, 17:02

@leosouza85 that's awesome to hear you're teaching people AutoHotkey! I tried doing it at Corporate America and the vast majority of people were just too lazy to bother learning anything. :(

I was actually discussing a similar idea of teaching AutoHotkey to people. If you'd be up for talking about the general idea sometime, reach out to me at [email protected]. I'd love to kick around ideas!

As for the simplistic approach, I didn't mean to say it was "bad". Just that I wouldn't do it myself. Every situation is different. One of the most important questions you have to ask is: "Will this script be run on other people's computers?" Virtually any time that happens, image search will break down. Personally I'd still just try and automate it in IE (if IE can load the page) If it can't then the Automate my Task is a really fast and easy solution that people can do on their computers. I just truly dislike any approach (including AMT) that ends up sending keystrokes or mouse clicks.

Find & Click AutoHotkey syntax writer Automate my Task :clap:
AHK Tutorials:Web Scraping | AHK Studio | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey :ugeek:
Connect with me on LinkedIn :beer: | YouTube
How-to: Create a shortcut that automatically
logs in to any website

:thumbup: Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Help support the AutoHotkey foundation
User avatar
metacognition
Posts: 97
Joined: 22 Oct 2014, 05:57
Location: Alaska

Re: Clicking on a text or link in google Chrome SIMPLE TUTORIAL (no COM or IMGSEARCH required)

04 Jan 2021, 01:34

This is what’s great about AutoHotKey, it’s ability to span the spectrum of skill/knowledge levels, it allows beginners a way to onboard at a very primitive level and, if they desire, ramp up to more advanced concepts like functions, classes and objects. Cool little trick for chrome! 👍🏻

Return to “Scripts and Functions”

Who is online

Users browsing this forum: jacek678, rafaltg2 and 27 guests