Sign in to follow this  
Followers 0
kalel69

IE objects exist check

4 posts in this topic

I asked this question in another post, but everyone ignored it, so I will ask it here in a new post... sorry for the redundency...

I have a web page that is slow to load at times, and I work in frames.

I've tried _LoadWait, but it returns before all the frames load, and the objects don't get created because it can't find the paths to the objects within the frames. If I put just sleep commands in it works but takes too long. I'd like it to return to the user after the page loads 100 % completely and my commands don't fail.

I've been doing it by checking isobj()

$Count = 0
Do
     $Count+=1
     $oIE = _IEAttachHDL($DQMwHndl)
     Sleep(200)
     If $Count > 10 Then
         MsgBox(0,$DQMerror1,$DQMerror2)
         Return
     EndIf
Until IsObj($oIE)

This works, but takes up CPU time checking a lot until the page loads. ($DQMwHndl is the handle to the IECREATE(web address) - _IEAttachHDL is a shorned version only using HWND's)

After the attach, I have to check for the frame, and form, using the same logic, or sometimes my script fails, as it cant get past all that stuff.

The short version:

$oIE = _IEAttachHDL($DQMwHndl)
$oIFrame = _IEFrameGetObjByName($oIE, "ifmPage")
$oForm = _IEFormGetObjByName($oIFrame, "frmADT")
$oSubmit = _IEGetObjByName($oForm, "button2")
$oSearchCompID = _IEFormElementGetObjByName($oForm, $CompanyPicker)
_IEFormElementSetValue($oSearchCompID,$ClientFacility)
_IEAction($oSubmit, "click")

the long version is what works, with each line above having a loop to check IsObj(). Basically because _loadwait() really doesn't work well. So each time I click a link, i have to verify all the objects again.

Func _ADTDefs()
If WinExists($DQMwHndl) Then
$oIE = _IEAttachHDL($DQMwHndl)
_IELinkClickByIndex ($oIE, $ClickADTDefSearch);link 43 search ADT defs.
Sleep(200)
$Count = 0
Do
$Count+=1
$oIE = _IEAttachHDL($DQMwHndl)
Sleep(200)
If $Count > 10 Then
MsgBox(0,$DQMerror1,$DQMerror2)
Return
EndIf
Until IsObj($oIE)
Sleep(200)
$Count = 0
Do
$Count+=1
$oIFrame = _IEFrameGetObjByName($oIE, "ifmPage")
Sleep(200)
If $Count > 10 Then
MsgBox(0,$DQMerror1,$DQMerror2)
Return
EndIf
Until IsObj($oIFrame)
Sleep(200)
$Count = 0
Do
$Count+=1
$oForm = _IEFormGetObjByName($oIFrame, "frmADT")
Sleep(200)
If $Count > 10 Then
MsgBox(0,$DQMerror1,$DQMerror2)
Return
EndIf
Until IsObj($oForm)
Sleep(200)
$Count = 0
Do
$Count+=1
$oSubmit = _IEGetObjByName($oForm, "button2")
Sleep(200)
If $Count > 10 Then
MsgBox(0,$DQMerror1,$DQMerror2)
Return
EndIf
Until IsObj($oSubmit)
Sleep(300)
$Count = 0
Do
$Count+=1
$oSearchCompID = _IEFormElementGetObjByName($oForm, $CompanyPicker);this is the call that is failing...
if @error then $Temp = 0;nothing
Sleep(400)
If $Count > 10 Then
MsgBox(0,$DQMerror1,$DQMerror2)
Return
EndIf
Until IsObj($oSearchCompID)
Sleep(400)
_IEFormElementSetValue($oSearchCompID,$ClientFacility)
Sleep(500)
_IEAction($oSubmit, "click")
EndIf
EndFunc

Is there a better way to make sure each object is a valid object other than what I preset here (too lengthy-not a clean script, too much CPU time) or a better way to ensure the page is really loaded instead of relying on LoadWait that will allow the short version to run properly?

Thanks in Advance!

Share this post


Link to post
Share on other sites



I asked this question in another post, but everyone ignored it, so I will ask it here in a new post...

Do you think opening a second thread on the same subject is a good idea?

This is no 24 hours support forum. If you don't get the replies you are waiting for, accept it.

There many threads without any reply. You got many, but obviously not the solution you are waiting for.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Water, are you in a bad mood today?

Why are you totally dis'sing my post without knowing the facts about it?

YOU are the one who totally ignored my previous post. It twas not a topic I created, rather than a reply under someone else post. I started by saying it was "a bit off topic but similiar", and NO ONE offered a peice of advice for me, rather just went on about that topic. check out this...

I am not asking for immediate repsonse, rather a newbie poster (9 posts here), and this is how you treat the newbies?

I don't want to start a flame war, i'm simply lookilng for help, and maybe the first place I posted this was the wrong place. So I posted it here instead. Thanks for understanding. But no thank you for the help.

Can someone ELSE please look at this?

Share this post


Link to post
Share on other sites

Not in bad mood but it seems I need glasses :whistle:

I was under the impression that the OP of the thread I referred to started a new one with the same content.

That's what happens when you "hijack" a thread. You should have opened a new one in the first place ^_^

The only help I can offer at the moment is:

Do not wait for the IE object to load but for a DOM element in your frames. The help file gives a bit more detail about this.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • chachew
      By chachew
      Is there an equivalent function to attach to a specific chrome tab?
      Similar to the IEAttach in e IE UDF
    • VixinG
      By VixinG
      Hey guys 
      I tried to attach to currently running Internet Explorer process, but without success.
      I even looped it, just like DaleHohm said
      $hWnd = WinGetHandle("Google - Windows Internet Explorer") Do Local $oIE = _IEAttach($hWnd, "HWND") Sleep(500) Until IsObj($oIE) MsgBox(0, "IE URL", _IEPropertyGet($oIE, "locationurl")) Sadly, it can't attach. I'm getting error:
      --> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch I was working on IE 9 before and couldn't attach, so I installed IE 10, hoping it will resolve this issue, but nope...
      Have you got any ideas?
      Would greatly appreciate any help!