Sign in to follow this  
Followers 0
Toolbox

obj.click hangs on IE.au3 line 2418

7 posts in this topic

Ok long story short, I am automating an .HTA window, and the script is hanging on line 2418 of IE.au3 which is '$o_object.Click()'.

Using AutoIt, I have gotten as far as finding all elements I need, a few element clicks and I get to a point where I need to click an anchor tag that I have grabbed as an object and done an obj.click on. This .click call invokes the onclick of the anchor which opens up a file browser. It hangs here.

I turned on the 'TrayIconDebug' option of the 'Opt' function and hovering over the tray tells me its hanging on a random (I say random only because it is different everytime) command that I know has already been executed. However, if I click the tray icon to pause it, hovering over it again tells me something different. It switches between telling me that it is paused on the obj.click call I mentioned earlier and '$o_object.Click()' which resides on line 2418 of IE.au3, which is called by the obj.click. So I know this is where it is hanging everytime.

If I manually click close and reclick the button, it will continue the script as if nothing happened. However, thats the only work around. Due to the fact that this hangs, placing a WinWaitActive or even a WinActivate after the .click is futile as the script never gets there, unless I do the aforementioned workaround.

So question(s)

1. Is there a way to terminate a single command (or even block of code, it makes no difference really) per use of a timeout/timer or any other automatic method?

2. Has anyone else had this issue and found a work around?

3. Does anyone know why this hang would be happening?

a.Possibly because the anchor tag or possibly the hta is not returning to the script until the browser window has been terminated?

b.Is this anchor tag not a feasible object for the .click command

(Knowing this is possible as I struggled to find clean ways of obtaining these objects, I had to use a script I found somewhere on the intertubes to search through each element, identifying it by class, as not all elements had ID tags)

4. Any suggestions? As this is a project for work, please understand that the hta code is not something I can reveal as well I as I hope that my explanation suffices for the autoit code because I am not entirely sure on the feasibility of that.

Share this post


Link to post
Share on other sites



Ah, the code for IE.au3 can be found here ...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

When a DOM action results in a dialog box being displayed that requires user interaction, control is not passed back to the calling routine until the user takes that action. This can be avoided by performing the 'click' using another method. Please see the third example for _IEAction in the helpfile for a work-around.

Dale

Edit: spelling

Edited by DaleHohm

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

When a DOM action results in a dialog box being displayed that requires user interaction, control is not passed back to the calling routine until the user takes that action. This can be avoided by performing the 'click' using another method. Please see the third example for _IEAction in the helpfile for a work-around.

Dale

Edit: spelling

Dale,

Thanks for the quick reply. I appreciate the explanation, it helps. Trying '_IEAction($obj, "click")' yields the same hang. I even tried

If _IEAction($obj, "click") Then
     MsgBox(0, "Success", "_IEAction has finished.")
Else
     MsgBox(0, "Error", @error & "_IEAction failure.")
EndIf

But we still encounter a hang at the same place.

Any other suggestions? Thanks for all the help in advance, its greatly appreciated.

Share this post


Link to post
Share on other sites

:light bulb:

The anchor click calls a js method that then calls to a separate module that does not return to the js until the file browser is terminated (by finishing or being closed). So in truth, the hang probably occurs here, and subsequently, I assume the click, whether it is an $obj.click or _IEAttach($obj, "click"), is waiting for the onclick handler of the anchor element, or obj as far as AutoIt is concerned, to return to the script (or however that works, as I am new to AutoIt, I can be wildly mistaken).

So, basically, what I am getting at, is it seems that unless there is a way to terminate a single line/block of code upon a variable timeout, I will have to figure out another fix.

Which lead me to the idea of simultaneous scripts. In AutoIt, is it possible to run simultaneous scripts? Using AutoIt itself or an outside language, possibly of an OO paradigm. In this case Ruby, as that is what I am using to run through all the scripts I am running.

For sake of clarity, lets call the script in question, Script A, the one hanging on the file browser. Lets then call a second script, Script B, whose purpose is to simply wait for the file browser to be opened, using a WinWaitActive or something similar.

Is it possible to invoke Script A and sometime before the click occurs in said script, invoke Script B from within Script A? This would require the script call to Script B to be simply a call with no wait and not a wait for completion (if you will) call. So essentially simultaneous scripting. As this is a scripting language, I foresee this not being possible.

Alternatively, using an OO language, is it possible to run the two scripts simultaneously? Does AutoIt allow two separate scripts to be ran at the same time?

Apologies for the long-winded approach, it was necessary to clearly demonstrate my question.

Share this post


Link to post
Share on other sites

I pointed you to the 3rd example for _IEAction... sorry there are only 2 and it is the second I meant to point you to. It does NOT use the .click method.

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

I pointed you to the 3rd example for _IEAction... sorry there are only 2 and it is the second I meant to point you to. It does NOT use the .click method.

Dale

Trying this no longer gives me the hang, but it does not click the button. I did some research on Ruby threading and found a way to run both scripts simultaneously. This seems to be the fix.

Thanks again for all the help Dale.

Tommy

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