Jump to content

Few questions


Recommended Posts

Hi!

I've been working on this all day and all night and it's not working as I want and I fell like trowing my computer out of the window.

Q1: Is there a beeter way to read a txt from the network

The txt file i only one line long and contains url adress

I have come up with

Func geturlopen()
    $IE = _IECreate ("http://......./open.txt", 0, 0, 1, -1)
    $sText = _IEBodyReadText ($IE)
    _IEQuit($IE)
    return $sText
EndFunc

because FileOpen() and FileRead() didn't work.

Q2: How to open a new IE behind all other windows

Here is what I've got but sometimes it doesn't work properly and I'm sure that there is a better way

Func urlopen($url)
    AutoItSetOption("WinTitleMatchMode", 2)
    $title = WinGetTitle("")
    $oIE = _IECreate ($url, 0, 1, 0, -1)
    WinSetState($oIE, "", @SW_HIDE)
    WinSetState("Internet Explorer", "", @SW_SHOWMINIMIZED)
    AutoItSetOption("WinTitleMatchMode", 1)
    WinActivate($title)
    WinWaitActive($title)
    AutoItSetOption("WinTitleMatchMode", 2)
EndFunc

Q3: Make this work

ok I have $time that gets is value from function very similar to geturlopen().

I want every $time minutes to call urlopen(geturlopen())

Also I want every sec to check if there is open a IE with specific url and close it.

Here is what I've got

while 1
    $j+=1
    if $j==60 Then
        $j=0
        $k+=1
    EndIf
    $urlopen = geturlopen()
    $urlclose = geturlclose()
    if $k==$time then 
        urlopen($urlopen)
        $k=0
    EndIf

Now I used two different otions for closing the IE with specific url

This is what I wrote initially (with little help from PsaltyDS)

$var = WinList("Internet Explorer")
For $i = 1 to $var[0][0]
    $iee = _IEAttach($var[$i][1], "HWND")
    $aa = _IEPropertyGet ($iee, "locationurl")
    if StringInStr($aa, $urlclose)<>0 Then  
        _IEQuit ($iee)
    EndIf
Next

but this doesn't work properly for IE 7 where there are many tabs. It also didn't work properly onother IE versions so I replaced it with what DaleHolum wrote

$o_Shell = ObjCreate("Shell.Application")
    $ies = $o_Shell.Windows (); collection of all ShellWindows (IE and File Explorer)

    _IEErrorHandlerRegister(); error will occur for File Explorer windows... allow ignore
    _IEErrorNotify(FALSE); suppress console error display

    For $ie In $ies
        $aa = _IEPropertyGet ( $ie, "locationurl" )
        If @error then ContinueLoop
            if StringInStr($aa, $urlclose)<>0 Then  
                _IEQuit ($ie)
        EndIf
    Next

The rest is just simple

Sleep(1000)
HotKeySet("^s", "Stop")
WEnd

Even with the DaleHolum code it doesn't work properly. Sometimes it gives me errors like

--> IE.au3 V2.3-1 Warning from function _IEAttach, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Error from function _IEPropertyGet, $_IEStatus_InvalidDataType

sometimes there is a error from _IECrate

but I think they come from my fnctions, not from his part

Also sometimes it closes window that shouldn't be closed, it changes active windows...

I think it will work ok if geturlopen() and urlopen() are fixed.

Please, help me make it work

Thank you for your time

I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more.

Link to comment
Share on other sites

  • 2 weeks later...

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...