How to click on specified text...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

How to click on specified text...

23 Apr 2018, 02:21

Image

Hi!

According to the image, I want the "Add to Cart" button to be pressed/clicked automatically as it appears, no matter where, and how many....

Please provide me the code to search for specified text and get it clicked...
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: How to click on specified text...

23 Apr 2018, 02:52

ImageSearch

Searches a region of the screen for an image.
ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
https://ahkde.github.io/docs/frame.htm# ... Search.htm

other exanoles of using: https://github.com/sl5net/global-Intell ... ns.inc.ahk
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

Re: How to click on specified text...

23 Apr 2018, 04:20

Thanks for the reply, the button is not an image, it's text format, "Add to Cart" can be found as text, so I was searching something like seeking for the particular word and click on that found area...
TinyDancer

Re: How to click on specified text...

23 Apr 2018, 04:44

VISHALVODRO wrote:Thanks for the reply, the button is not an image, it's text format, "Add to Cart" can be found as text, so I was searching something like seeking for the particular word and click on that found area...
its a webpage? maybe use com, it can do the job fast
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

Re: How to click on specified text...

23 Apr 2018, 06:54

TinyDancer wrote:
VISHALVODRO wrote:Thanks for the reply, the button is not an image, it's text format, "Add to Cart" can be found as text, so I was searching something like seeking for the particular word and click on that found area...
its a webpage? maybe use com, it can do the job fast
Dear, can you give me sort of example related to that?

Yes, it's Amazon, I'm trying to catch the lightning deals...
TinyDancer

Re: How to click on specified text...

23 Apr 2018, 07:32

VISHALVODRO wrote:
TinyDancer wrote:
VISHALVODRO wrote:Thanks for the reply, the button is not an image, it's text format, "Add to Cart" can be found as text, so I was searching something like seeking for the particular word and click on that found area...
its a webpage? maybe use com, it can do the job fast
Dear, can you give me sort of example related to that?

Yes, it's Amazon, I'm trying to catch the lightning deals...
post a sample url
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

Re: How to click on specified text...

23 Apr 2018, 20:41

TinyDancer wrote:
VISHALVODRO wrote:
TinyDancer wrote:
VISHALVODRO wrote:Thanks for the reply, the button is not an image, it's text format, "Add to Cart" can be found as text, so I was searching something like seeking for the particular word and click on that found area...
its a webpage? maybe use com, it can do the job fast
Dear, can you give me sort of example related to that?

Yes, it's Amazon, I'm trying to catch the lightning deals...
post a sample url
https://www.amazon.in/gp/goldbox/all-de ... a,b11a9b56

Check out the link, I want AHK to press those "Add to Cart" button automatically...

Thanks dear
TinyDancer

Re: How to click on specified text...

24 Apr 2018, 02:46

VISHALVODRO wrote:
TinyDancer wrote:
VISHALVODRO wrote:
TinyDancer wrote:
VISHALVODRO wrote:Thanks for the reply, the button is not an image, it's text format, "Add to Cart" can be found as text, so I was searching something like seeking for the particular word and click on that found area...
its a webpage? maybe use com, it can do the job fast
Dear, can you give me sort of example related to that?

Yes, it's Amazon, I'm trying to catch the lightning deals...
post a sample url
https://www.amazon.in/gp/goldbox/all-de ... a,b11a9b56

Check out the link, I want AHK to press those "Add to Cart" button automatically...

Thanks dear
Here is the code for that page, I included some notes. Because you never know how many add to cart buttons there will be we must do a loop to first check how many buttons are there, then, the system goes to the buttons and clicks

you might be able to remove or you might need to add some more or less sleep

also for now i have it set to show you the browser window, but you can change it on line 2, the messagebox at end you dont need its just there to test to make sure the program picks up how many buttons we have

Code: Select all

pwb := ComObjCreate("InternetExplorer.Application")
pwb.Visible := True ; change to False to hide IE window
pwb.Navigate("https://www.amazon.in/gp/goldbox/all-deals?ie=UTF8&gb_edi=c0e585ea,b11a9b56")

while pwb.ReadyState != 4
	sleep, 1000

sleep, 2500

amazon1 .= pwb.document.getElementsByTagName("BUTTON").length
loop, %amazon1%{

amazon2 .= pwb.document.getElementsByTagName("BUTTON")[ A_index -1 ].Click() "`n"
;sleep, 3000 ; you might need this for the page to work 
}
msgbox, Clicked on %amazon1% Buttons

pwb.quit()
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

Re: How to click on specified text...

24 Apr 2018, 04:43

Dear,
Thank for your effort and support.

I don't want the script to open the link itself, it just needs to work upon running the file.

Now it opens by default on IE Browser which doesn't seem to be working well, if it opens on chrome, works better.

Thanks in advance...
TinyDancer

Re: How to click on specified text...

24 Apr 2018, 05:15

VISHALVODRO wrote:Dear,
Thank for your effort and support.

I don't want the script to open the link itself, it just needs to work upon running the file.

Now it opens by default on IE Browser which doesn't seem to be working well, if it opens on chrome, works better.

Thanks in advance...
To work with chrome you will need to use this https://autohotkey.com/boards/viewtopic.php?f=6&t=42890

I am not familiar with chrome fore automation

If all the buttons are visible on the screen and you dont have to scroll, you can use image search and that will work on any browser but the screen must be active and the buttons visible

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: joedf, OrangeCat, scriptor2016 and 126 guests