Jump to content

_IEGetObjByName warnings and code tweaking


 Share

Recommended Posts

With the help of a number of people on here I’ve managed to get my first script into a working state. Basically it reads a csv file of variables, pastes them one at a time to a web page whilst clicking a few buttons to process them through a sequence/loop of pages.

One of the issues I ran in to was that whilst the HTML on one page refreshes the browser and tab titles do not change, meaning I could not use WinWaitActive which is what I’ve used for the other pages.

I coded this instead, ‘SUB’ being the button name:

Sleep(500)

Local $oContinue = _IEGetObjByName($oIEconfirm, "SUB")

While @error

Sleep(250)

Local $oContinue = _IEGetObjByName($oIEconfirm, "SUB")

WEnd

_IEAction($oContinue, "click")

Whilst this works, is there a better way of achieving this button click?

Before I moved the Sleep(500) to where it is and introduced the Sleep(250) I was getting a lot of timeouts for _IEGetObjByName, e.g.:

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

Once that got to around 100 triggers things get a bit unstable. Script execution hung and I was seeing a 10 or more minitiure AutoIt icons on the status area of the Windows Start bar, where there is nornally one whils the script runs. Is there a limit to the number of warnings that can be encountered/handled? This is slightly academic, as the Sleep statements have reduced the occurance of the warnings but it would be nice to be aware of any limitations that might be re-exposed if/when the latency/cycle time of the transactions increased.

One final newbie question, is it possible to have the script and windows run in the background/independent of focus?

Thanks in advance!

Link to comment
Share on other sites

Sleep(500)
Local $oContinue = _IEGetObjByName($oIEconfirm, "SUB")
While @error
Sleep(250)
Local $oContinue = _IEGetObjByName($oIEconfirm, "SUB")
WEnd
_IEAction($oContinue, "click")

Whilst this works, is there a better way of achieving this button click?

Try this:

_IELoadWait($oIEconfirm)
While Not _IEGetObjByName($oIEconfirm, "SUB")
Sleep(250)
WEnd
Local $oContinue = _IEGetObjByName($oIEconfirm, "SUB")

Is there a limit to the number of warnings that can be encountered/handled?

No, not to my knowledge.

One final newbie question, is it possible to have the script and windows run in the background/independent of focus?

If you're speaking of having IE run in the background, without the need for window focus, you might consider using _IEAttach to create additional objects as needed--such as $oIE, $oIEconfirm, $oIEpopup, etc.--and can be hidden.
Link to comment
Share on other sites

The 'While Not _IEGetObjByName($oIEconfirm, "SUB")' construct doesn't work; running in debug I can see a number of NoMatch warnings, they then go away but it keeps cycling round the loop. Not to worry it's a minor point.

I'm already using WinWaitActive and _IEAttach for most of the work. I'd rather the pages remained visible, or at least accessible - so progress is obvious/can be checked. Given that removing focus by clicking away to another window - or minimising the window - causes the WinWaitActive called before the _IEAttach to fail, is what I've done fundamentally incompatible with making things focus insensitive?

Edited by imacleod
Link to comment
Share on other sites

Mmm, now I discover that the script pauses when the screen is locked. That's not good given it takes 6 minutes per hundred cycles and there are up to 2500 in each batch...

Is there anything I can do with this? Disabling the screen save lock isn't a good option;-)

Edited by imacleod
Link to comment
Share on other sites

I'm just copying and pasting a piece of what I wrote in another thread earlier:

http://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F

Using WinExists will work (loop until it does), and then wait for the WinGetState to include is visible, and is enabled...then use controlsend instead of send

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...