LClick not Clicking

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
idw456
Newbie
Posts: 3
Joined: Tue Mar 13, 2018 4:06 am

LClick not Clicking

Post by idw456 » Fri Mar 16, 2018 1:30 am

When accessing a website, https://shareinvesting.anz.com/home.aspx. I can manually click on "My Portfolio" This operates and asks for UN and Pw.

I automated this using the "IE Element Wizard", which produced:

Code: Select all

IEClickTag>%IE[0]%,{""},{""},{"IMG"},{"ID"},{"PT Portfolio Landing Page_IMG"},ie_res
However this is not reliable as the site changes the number of images and the wrong image can be clicked, but the click does work.

To overcome this I used the "Image Recognition Wizard", which I think should solve all the problems.

The image is found and the mouse pointer moves to the correct position, but the following LClick does not click.

Note that the mouse pointer is a "hand" and not a "pointer", a possible reason?

A full test script is as follows, image_1.bmp needs to be recreated.

Code: Select all


//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

// Generated by MacroScript WebRecorder 4.04
// Recorded on Thursday, March 15, 2018, at 04:15 PM
//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
//Set timeout for ClickTag and FormFill to 10 seconds, increase if pages load more slowly
IESetTimeout>10,ie_res
IECreate>IE[0]
IENavigate>%IE[0]%,https://shareinvesting.anz.com/Home.aspx,ie_res
IEWaitDocumentComplete>%IE[0]%,ie_res
WindowAction>1,ANZ Share Investing | Online Share Trading - Internet Explorer

/* Click within IEClickTag works but unreliable as the number of images on web page changes

IEClickTag>%IE[0]%,{""},{""},{"IMG"},{"ID"},{"PT Portfolio Landing Page_IMG"},ie_res
*/

// LClick does not work 
//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  LClick
Endif

IEWaitDocumentComplete>%IE[0]%,ie_res

Ian Watts

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: LClick not Clicking

Post by Marcus Tettmar » Fri Mar 16, 2018 8:19 am

LClick *must* click. It blindly sends a mouse down event. It can't ever fail to do that. So if it doesn't have an effect the issue must be that it's clicking in the wrong place or at the wrong time, or perhaps the window you're clicking in isn't focused (sometimes a window needs focusing before a click can work).

I would try:

1. Before the FindImagePos make sure the window is focused with SetFocus
2. Before the LClick issue a short wait to allow time between the cursor getting there and the click: Wait>0.05
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts