Jump to content

Clicking a tricky browser button (solved)


Nevin
 Share

Recommended Posts

Okay, here's my problem. I do data entry, and I have to fill the same form out over and over.

Here's the part of the form I'm having trouble with:

Posted Image

Here's a summary for those who don't want to read it all:

I need to click the button indicated in the above picture

1. I can't reliably use MouseClick (as far as I know)

2. I can't {TAB} to it.

3. I hate my life <_<

1. The problem? That damn add button that I pointed to. I need to click it! I want this to work on any machine its put on, so I can't just use a MouseClick. If I do that, the resolution of the machine will make it miss where the button is. Even if I write the script for all resolutions, theres still the issue of people having stupid toolbars and whatnot in their browsers, changing the location of the buttons on the screen. It seems like whatever I do doesn't work.

2. What I've been doing to get around the form is just pressing tab. This makes the keyboard focus move from box to box..and it even selects buttons. For some reason, however, it does not select this one. Tab will put the focus on the "top" button, the "Cancel" button, and basically any button in the form except the add button, it skips right over it! That means this won't work either.

3. Since I can't figure out how to single out the button, I was thinking maybe I could somehow single out the text box to the left of it. I put the keyboard focus in it and ran a program to get the controlID and handle for the textbox. Unfortunately, they're the same for every box. I don't know if that is unique to this form, or if I don't know what the heck I'm doing. (I'm not too savvy with handles and controlIDs). ControlID=Internet Explorer_Server1 handle=0x000802D0 Window Class:IEFrame

This form is in a browser, anyone using the program will be running IE. I'd love to let you guys use it, but then you'd need the password. :)

Any ideas? Very much appreciated. I just recently discovered UDFs, and didn't even know there was a set of _IE ones, but I don't know enough about IE to understand all those objects and whatnot to know if that would even help.

Edited by Nevin
Link to comment
Share on other sites

I just recently discovered UDFs, and didn't even know there was a set of _IE ones, but I don't know enough about IE to understand all those objects and whatnot to know if that would even help.

The _IE* functions, all contained in the IE.au3 UDF, are included with AutoIt for the last several versions, and are therefore listed with lots of excellent example scripts in the help file.

Try the example scripts, then code up your script. If you get stuck, post your code for more help.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Interesting. I missed that one, but now that I look at the remarks..

Remarks

For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom Javascript tied to an onclick event for its Submit button. In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction().

As well, some form processing relies on the "value" of the submit button being passed along with the rest of the form data (often when there is more than one submit button in the form and they are designed to trigger different results). This function will not result in a submit button value being passed. The solution is to use the "click" action of _IEAction() as above.

If you experience trouble with the automatic _IELoadWait called by default, please set $f_wait parameter to 0 and call _IELoadWait from your script, passing it the InternetExplorer object.

I know this form definitely uses some java, and this particular button, when clicked, must pass the number placed in the textbox to the left of it, so that means I'd have to use the "click" action of _IEAction(), as it mentions in the bottom of paragraph two.

edit: Just saw Psalty's reply.

I'll gladly try to figure out all this IE stuff, but I don't understand what the $o_object is, and how to find it. That's why the IE UDFs all confuse me.

Edited by Nevin
Link to comment
Share on other sites

Interesting. I missed that one, but now that I look at the remarks..

I know this form definitely uses some java, and this particular button, when clicked, must pass the number placed in the textbox to the left of it, so that means I'd have to use the "click" action of _IEAction(), as it mentions in the bottom of paragraph two.

edit: Just saw Psalty's reply.

I'll gladly try to figure out all this IE stuff, but I don't understand what the $o_object is, and how to find it. That's why the IE UDFs all confuse me.

No big deal. Just means you've got a little learning curve to overcome. Again, the example scripts that accompany each function in the help file are generally very good. Dale made the ones for the _IE* functions even better by including some example.html pages to work with.

To get you started: An object is a special kind of variable that points to an interface for something. That interface has predefined methods and properties associated with it. When you create an instance of IE in memory with _IECreate() it returns the object reference you can use later to access all those method and properties. By convention, object variables in AutoIt start with 'o', so creating two instances of IE might look like this:

#include <IE.au3>

$oIE_1 = _IECreate("http://www.mozilla.com")
$oIE_2 = _IECreate("http://www.openoffice.org")
Sleep(2000)
_IEQuit($oIE_2)
Sleep(2000)
_IEQuit($oIE_1)

Spend some time with those example scripts. It's well worth learning.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

*Inserts foot in mouth*

So I've been fooling around with the IE UDFs for the last 50 minutes..and I've figured out how some of it works, but I still have no idea how to do what I wanted lol. My current pseudocode:

_IEAttach the window I'm working in

_IEAction to click on the button I want

That's it, lmao.

I attached the window via Title, I don't know if that's okay or not, because it uses frames, but I don't know what else to do.

As for the _IEAction, how the heck do I know what the elements name is? I read about _IEGetObjByName and _IEGetObjByID, but then I need the Name or ID..I don't know where to get it from. :)

While messing around, I also tried _IETableGetCollection and it said there were zero tables for the browser I attached it to (the one in the picture in my original post), so I'm guessing I'm using some kind of evil form, or I messed up something.

<_< I'm having a mental breakdown

(I double posted since editing wouldn't let anyone know I said something)

Link to comment
Share on other sites

You not going to get discussions of a thousand generalities here.

1. Pick the example script from one of the _IE* commands (the that comes closest to matching what you want to do in the end).

2. Try to run it from SciTE, and read it carefully.

3. When you get down to the first thing you just don't understand, post a specific question about that particular script and function.

Once you get to writing your own code, if you get stuck post the code with your question. It shaves off a lot of irrelevant non-sense to talk about some specific code.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ermm. I think I made my last post too confusing. All I need to know is how to click that "ADD" button with _IEAction, my problem being that the function requires the $o_object of that button. I don't know how to get the $o_object for the button.

I don't get how writing the code will help, but just in case:

#include <IE.au3> 
$oIE = _IEAttach ("Provider")
$oAddButton = _IEGetObjByName ($oIE, "?????")
_IEAction ( $oAddButton,"click")

OR

#include <IE.au3> 
$oIE = _IEAttach ("Provider")
$oAddButton = _IEGetObjById ($oIE, "?????")
_IEAction ( $oAddButton,"click")

edit: Had too many question marks :">

Edited by Nevin
Link to comment
Share on other sites

... the name or the object id...

ok so for example here is a script that clicks the search button on the google front page-

#include <IE.au3>

$obj=_IEAttach("Google")    ;Attaches to a browser with google in teh title
$button=_IEGetObjByName($obj,"btnG")   ; gets a object referrnce by the name of the control, in this case btnG
_IEAction($button,"click")  ; clicks the button

You can look at the source of the page to get the name... see the attachment for the google example... the button is circled in red, the name is in blue

edit: sry, wrong attachment *fixy*

edit 2: removing picture to save attachment space.

Edited by evilertoaster
Link to comment
Share on other sites

Please install DebugBar (see my sig) -- free tool -- you'll be amazed how quickly the doors will open for you.

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

Link to comment
Share on other sites

Please install DebugBar (see my sig) -- free tool -- you'll be amazed how quickly the doors will open for you.

Dale

Sweet. Now I don't even have to hunt through the code (that I just finally found). Thanks <_< Group hug.

Hell, maybe I'll rewrite my whole program now, to write directly to the controls instead of using ControlSend. (1455 lines >.<)

Link to comment
Share on other sites

Another issue. I got this to work fine in the IE_Example form file, but not the form I'm writing the real script for.

Code:

#include <IE.au3>
$oIE = _IEAttach("Provider Site")
$addbox = _IEGetObjByName($oIE,"serviceLineNum")

Error: IE.au3 Warning from function _IEGetObjByName, $_IEStatus_NoMatch

Does this mean that "serviceLineNum" is the wrong name for the object? How can that be? Here's a picture of the object name

Thanks again. I can't wait until this is all over <_<

Link to comment
Share on other sites

Frame or iFrame.

ConsoleWrite(_IEDocReadHTML($oIE) & @CR)

will likely show you that $oIE is not what you think it is.

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

Link to comment
Share on other sites

Frame or iFrame.

ConsoleWrite(_IEDocReadHTML($oIE) & @CR)

will likely show you that $oIE is not what you think it is.

Dale

Yup, it's not. I originally thought that was the problem, but then I wasn't sure. I've tried a lot of things. If I view the source of the frame I want, I found the title tags, and they say

<title>Claim Submission</title>

Doesn't this mean I should use:

$oIE = _IEAttach("Claim Submission")

I tried that, didn't work. NoMatch for _IEAttach. I also tried

$oIE = _IEAttach("Claim")

$oIE = _IEAttach("Claim","WindowTitle")

$oIE = _IEAttach("Claim Submission","WindowTitle")

All of a sudden, this language makes me feel retarded. Good thing I'm a Networking Major. <_<

Another picture, weeee.

Posted Image

I found the title tag in the debugbar, and it says the same thing, "Claim submission". Do I have to identify the window another way?

This may be a good time to mention this again. The window is one of those Internet Explorer_Server1 deals, as (you?) mentioned in the Remarks of IEAttach:

Remarks

_IEAttach provides the "DialogBox" parameter to attach to modal and modeless dialogs created by the browser. It is important to note that not all dialogs created through browser interaction can be attached to and controlled in this way. Many of these dialogs are actually standard windows and can be controlled through the traditional AutoIt window functions. A reliable way to tell the difference between these types of windows is to use the "AutoIt Window Info" tool to examine it -- if the window contains a control called "Internet Explorer_Server1" then you can attach to it with this function, if it does not it is a standard window and traditional AutoIt windows functions must be used to control it.

Does this mean I should use the DialogBox parameter? If so, what the heck goes in it?

Edited by Nevin
Link to comment
Share on other sites

No, you need to use the _IEFrame* functions.

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

Link to comment
Share on other sites

Phew. I was about to give up, too.

Got it to work like so:

$oIE = _IEAttach("Provider")
$oFrame = _IEFrameGetObjByName ($oIE, "Main")
$addbox = _IEGetObjByName($oFrame,"serviceLineNum")

Thanks for having patience. You must have some crazy good karma <_<

Now I just need to click the silly button that says add. It's a Java-related button, so I know I'm supposed to use _IEAction($addbutton,"click")

The button, however, has no Name or ID, that I can see.

<img BORDER="0" ALT="add"
    src="/provider/images/buttons/add.gif"
    onmouseover="java script:style.cursor='hand';"
    onclick="java script:goTo('AddLineItem')">

Let's kick it in the nuts. Who is with me?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...