Sign in to follow this  
Followers 0
ionmang20

Click on a button using IE functions

12 posts in this topic

I've made an application in AutoIt that notifies me of changes in my internet banking balance.

Because I used unreliable commands like Send("{ENTER}")to hit Ok button, Send("User{TAB}Password{ENTER}") to enter the user name and password in a login form or ControlClick("Title", "","", "", 1, X, Y) to click on a link or button at x , y coordinates , I decided to improve my script with IE functions.

I tried to apply IE functions to click the top Ok button from https://bt24.btrl.ro/bt24 like the picture below :

#include
$IE = _IECreate("https://bt24.btrl.ro/bt24", 0, 1, 0, 1)
_IELoadWait ($IE)
$ID = _IEGetObjByName($IE,"rghtsidbtna")
_IEAction ($ID, "click")
MsgBox(0, "Result", "IE " & $IE & @CRLF & "ID "& $ID & @CRLF & "Error " & @error)

post-56641-12700334029183_thumb.jpg

The object name “rghtsidbtna” I’ve got it with DebugBar and I hope it’s right :

<IMG border=0 name=rghtsidbtna alt="" src="images/rghtsidbtna.gif" width=39 height=26>

But the button isn't clicked (although I hear the clicking sound) and the variables $IE = “”, $ID= “”, @error = 0

post-56641-12700337066437_thumb.jpg

Can you tell me what I’ve done wrong and how can I click that button?

Share this post


Link to post
Share on other sites



It's not a button, it's a picture with an underlying java-script... and as far as I can see on that page it doesn't trigger anything expect an img-change :(? Nothing happens when I click on it and I can't see any trigger in the source too...

Share this post


Link to post
Share on other sites

It's not a button, it's a picture with an underlying java-script

Yes, you are right, it's picture, but how can I click on it ?

and as far as I can see on that page it doesn't trigger anything expect an img-change :(? Nothing happens when I click on it and I can't see any trigger in the source too...

I don't understand why nothing happens, because when I click the Go picture next to login, it opens a pop up window https://bt24.btrl.ro/bt24/SSL/default.asp?Language=Romanian

Can you try clicking on any of the Go pictures on the left, also them will do something ?

Share this post


Link to post
Share on other sites

I see, might get killed by a pop-up blocker here :( ... seems like a static address to me... why don't you just use it as the start-page for _IECreate() directly?

Share this post


Link to post
Share on other sites

I see, might get killed by a pop-up blocker here :( ... seems like a static address to me... why don't you just use it as the start-page for _IECreate() directly?

Yes, I could do that, but I what to learn how to do that with your help and because the access in the page is restricted by a certificate you cannot see the page in order to help me.

So, how can I use the IE functions _IECreate, _IEGetObjByName and _IEAction or any other function to click on this page pictures ?

Share this post


Link to post
Share on other sites

I tried _IEImgClick() which returns a -1 (success)... but nothing happens... strange :(... maybe it has something to do with https protocol?

Share this post


Link to post
Share on other sites

I tried _IEImgClick() which returns a -1 (success)... but nothing happens... strange :(... maybe it has something to do with https protocol?

I tried with _IEImgClick,but it returns 0, did I do anything wrong ?

#include <IE.au3>
$IE = _IECreate("https://bt24.btrl.ro/bt24")
_IELoadWait ($IE)
_IEImgClick($IE,"rghtsidbtna","name")
MsgBox(0, "Result", "IE " & $IE & @CRLF & "ID "& $ID & @CRLF & "Error " & @error)

Share this post


Link to post
Share on other sites

No, the protocol is not the issue.

You'll see that the img is nested in an <A> with a bunch of javascript tied to it... that is where the magic is happening.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

No, the protocol is not the issue.

You'll see that the img is nested in an <A> with a bunch of javascript tied to it... that is where the magic is happening.

Dale

I tried :

#include <IE.au3>
$IE = _IECreate("https://bt24.btrl.ro/bt24")
_IELoadWait($IE)
$ID = _IEGetObjByName($IE, "A")
_IEImgClick($ID, "rghtsidbtna", "name")

... it doesn't click on the image and I get the following errors :

--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: A, Index: 0)
--> IE.au3 V2.4-0 Error from function _IEImgClick, $_IEStatus_InvalidDataType

How can I access the img in the <A> </A> ?

Share this post


Link to post
Share on other sites

You'll see that the img is nested in an <A> with a bunch of javascript tied to it... that is where the magic is happening.

Dale

I fear that Dale means it's necessary to analyze the underlying javascript (saw a ref to a .js file at the top of the source) to emulate what's happening. So a click to an image is only meant literally and not really performed as by user input?

Share this post


Link to post
Share on other sites

I fear that Dale means it's necessary to analyze the underlying javascript (saw a ref to a .js file at the top of the source) to emulate what's happening.

I noticed with DebugBar that onmousedown="changeImages('rghtsidbtna', 'images/rghtsidbtna-over.gif'); go_ib(); return true;" and so I downloaded the website with Teleport.

In choosepg.js I founded :

function go_ib()
{
    var width, height;
    height = screen.availHeight - 40;
    width = screen.availWidth - 10;
    window.open('https://bt24.btrl.ro/bt24/SSL/default.asp?Language='+prev_language, 'IB', 'toolbar=no,resizable=yes,top=0,left=0,width='+width+',height='+height, '');
}

...now how can I run go_ib() function ?

So a click to an image is only meant literally and not really performed as by user input?

I'm affraid I don't understand the question. You mean I shouldn't click on the image and do something in order to get the same effect ?

Share this post


Link to post
Share on other sites

You mean I shouldn't click on the image and do something in order to get the same effect ?

Yeah, it seems to me that emulating the click does not trigger the underlying javascript...

window.open('https://bt24.btrl.ro/bt24/SSL/default.asp?Language='+prev_language, 'IB', 'toolbar=no,resizable=yes,top=0,left=0,width='+width+',height='+height, '');

So why do you need to call the start-up page first? To acquire the certificate? Maybe something like this is sufficient too?

#include <IE.au3>
$oIE= _IECreate("https://bt24.btrl.ro/bt24")
_IELoadWait($oIE)
_IENavigate ($oIE, "https://bt24.btrl.ro/bt24/SSL/default.asp?Language=Romanian")

or, if the target page checks for referer something like this...

#include <IE.au3>
$oIE = _IECreate("https://bt24.btrl.ro/bt24")
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, "<a id='custom_entry' href='https://bt24.btrl.ro/bt24/SSL/default.asp?Language=Romanian'>custom_entry</a>", "afterbegin")
_IELinkClickByText ($oIE, "custom_entry")

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0