Jump to content
iamtech

Check url in internet explorer

Recommended Posts

iamtech

i want to repeat my code until 'xyz' website not exists. its possible ?

i am know about If StringInStr(_IEBodyReadHTML($oIE), "docid"), but i want to know about locationurl.

Share this post


Link to post
Share on other sites
Danp2

If you only need to check the current tab, use _IEPropertyGet to retrieve the locationurl. Otherwise, you could use _IEAttach.

Share this post


Link to post
Share on other sites
iamtech
1 hour ago, Danp2 said:

If you only need to check the current tab, use _IEPropertyGet to retrieve the locationurl. Otherwise, you could use _IEAttach.

which loop statetment i can use ?

Share this post


Link to post
Share on other sites
Danp2

This is directly from the help file (you do know how to open it, right? :blink:) --

; Create an array of object references to all current browser instances
; The first array element will contain the number of instances found

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $aIE[1]
$aIE[0] = 0

Local $i = 1, $oIE
While 1
    $oIE = _IEAttach("", "instance", $i)
    If @error = $_IEStatus_NoMatch Then ExitLoop
    ReDim $aIE[$i + 1]
    $aIE[$i] = $oIE
    $aIE[0] = $i
    $i += 1
WEnd

MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0])

You should be able to adapt this to your needs.

Hint: Drop the array stuff and add some code to check the locationurl.

Share this post


Link to post
Share on other sites
iamtech
1 hour ago, Danp2 said:

This is directly from the help file (you do know how to open it, right? :blink:) --

; Create an array of object references to all current browser instances
; The first array element will contain the number of instances found

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $aIE[1]
$aIE[0] = 0

Local $i = 1, $oIE
While 1
    $oIE = _IEAttach("", "instance", $i)
    If @error = $_IEStatus_NoMatch Then ExitLoop
    ReDim $aIE[$i + 1]
    $aIE[$i] = $oIE
    $aIE[0] = $i
    $i += 1
WEnd

MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0])

You should be able to adapt this to your needs.

Hint: Drop the array stuff and add some code to check the locationurl.

@Danp2 i create code like this :

Do
; Some Code here
until _IEPropertyGet($oIE,"locationurl") = "my website"

its right ?

Share this post


Link to post
Share on other sites
Danp2

@iamtech Only you can answer that question. :lol: Does the code do what you need it to do? In your original post you stated

4 hours ago, iamtech said:

i want to repeat my code until 'xyz' website not exists. its possible ?

The code you posted will loop until the current URL equals your designated website, so that seems to be the opposite of your original goal.

Perhaps you should restate your goal. Be sure to indicate if the requirement is to check all tabs or only the current one.

Share this post


Link to post
Share on other sites
iamtech
Posted (edited)
14 minutes ago, Danp2 said:

@iamtech Only you can answer that question. :lol: Does the code do what you need it to do? In your original post you stated

The code you posted will loop until the current URL equals your designated website, so that seems to be the opposite of your original goal.

Perhaps you should restate your goal. Be sure to indicate if the requirement is to check all tabs or only the current one.

Sorry @Danp2 , beacuse my english is not very well ?

i want to check only current tab, and my question is if website "xyz" exists then stop code repeat.

i tested this code 

Do
; Some Code here
until _IEPropertyGet($oIE,"locationurl") = "my website"

and it was woek for me, But _ieloadwait not working after url exist

my full code is :

#include <IE.au3>
#include <MsgBoxConstants.au3>

Opt("TrayAutoPause",0)
HotKeySet("{ESC}", "Quit")

Func Quit()
    Exit
 EndFunc
 
 $oIE = _IEAttach ("xyz")
$body = _IEBodyReadHTML($oIE)

_IELoadWait($oIE)

Local $oTds = _IETagNameGetCollection($oIE, "td")
For $oTd In $oTds
    If $oTd.InnerText = "0.000" Then
_IENavigate($oIE, "https://url1")
Exit
EndIf
Next

Do
   _IENavigate($oIE, "https://url2")
_IELoadWait($oIE)

If StringInStr(_IEBodyReadHTML($oIE), "ocid") Then
$document = _IEFormGetCollection ($oIE,0)
$documentopt = _IEFormElementGetObjByName ($document, "document")
_IEFormElementOptionselect ($documentopt, 1, 1, "byValue")
$docno = _IEGetObjByName($oIE,"docno")
_IEPropertySet($docno,"innertext", Random(112,99629,1))
$btn = _IEGetObjById($oIE,"btn")
_IEAction($bt,"click")
EndIf
$consent = _IEGetObjById($oIE,"consent")
_IEAction(consent,"click")
_IELoadWait($oIE)

$imgb = _IEGetObjById($oIE,"imgb")
_IEAction($imgb,"click")
Sleep(2000)
Until _IEPropertyGet($oIE,"locationurl") = "url2"

_IELoadWait($oIE)
If StringInStr($body, "Details") Then
$btnselect = _IEGetObjById($oIE,"btnselect")
_IEAction($btnmemberselect,"click")
_IELoadWait($oIE)
$member = "selected"
Local $oTds = _IETagNameGetCollection($oIE, "td")
For $oTd In $oTds
    If $oTd.InnerText = $member Then
        $member = $oTd.NextElementSibling.InnerText
next
        
    MsgBox(64+$MB_TOPMOST, "Saved Successful" , "You saved the following file :" & @CRLF & $member, 1)

 

Edited by iamtech
_ieloadwait not working

Share this post


Link to post
Share on other sites
iamtech
1 hour ago, Danp2 said:

Then the code you posted should work.

@Danp2 it was not working after checking url exists, the script is exit after 

Until _IEPropertyGet($oIE,"locationurl") = "url2"

Share this post


Link to post
Share on other sites
Danp2

@iamtech Not sure what you expect us to do about it. You post a bunch of code that we can't actually run and you don't provide any context of what is supposed to be happening within this Do...Until loop. On the surface, it appears that you navigate to url2 at the beginning of the loop and therefore the loop exits when you hit the check at the bottom.

What am I missing?

Share this post


Link to post
Share on other sites
iamtech
11 minutes ago, Danp2 said:

@iamtech Not sure what you expect us to do about it. You post a bunch of code that we can't actually run and you don't provide any context of what is supposed to be happening within this Do...Until loop. On the surface, it appears that you navigate to url2 at the beginning of the loop and therefore the loop exits when you hit the check at the bottom.

What am I missing?

Sorry @Danp2 this is gujarat goverment site and it was not opened without my username and password, then i can't give you full url.

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

×