Manually trigger IE onClick event

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Dominic_Fichera
Pro Scripter
Posts: 82
Joined: Mon Mar 24, 2014 12:15 pm

Manually trigger IE onClick event

Post by Dominic_Fichera » Tue Jan 10, 2017 11:03 pm

Hi All,

wondering if anyone has come across a way to manually trigger an "onClick" event associated with a button within a page?

At the moment, the only way for my to get it working with the web recorder is to have the mouse hover over a button on a page which then shows the "download" button. This becomes a bit of a problem if I want to run the script with the PC screen locked. I have also tried using an IEClickTag function, but this doesn't successfully emulate a "hover" action to show the button.

In my specific instance, the HTML is as follows:

Code: Select all

<input name="downloadFile" type="button" class="button" value="Download" onclick="startDownload('filename')">
And the part I want to manually trigger is:

Code: Select all

onclick="startDownload('filename')"
Hope this makes sense! Also open to alternatives.

Dominic Fichera

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

Re: Manually trigger IE onClick event

Post by Marcus Tettmar » Wed Jan 11, 2017 10:52 am

Try UIClick - the UI functions sometimes work with web elements. Or Image Recognition.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

Re: Manually trigger IE onClick event

Post by zabros2020 » Thu Jan 19, 2017 2:50 am

Fully agree with Marcus.
I had a similar issue with one of the applications i needed to automate. I could not trigger the click in any of the web recorder functions. So i used the UIClick function and it solved my problem and will still work even if the screen is locked. I tried it.
Here is a little example:

Code: Select all

Let>url=http://www.google.com/
IECreate>ie
IEGetHWND>ie,ieHnd
IENavigate>%ie%,%url%,res
IEWaitTimeout>%ie%,3,0.2,res
Let>WIN_USEHANDLE=1
UIClick>%ieHnd%,{"I'm Feeling Lucky"}
IEWaitTimeout>%ie%,3,0.2,res
Loving MS's Capabilities!!!

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