Jump to content

Reload every feature in my browser


Recommended Posts

I created a browser in AU3 and I want to make a feature that reloads the intenet page every sometimes.

I tried this kind of script:

#include <GUIConstants.au3>
#include <IE.au3>

GUICreate("Browser", 601, 401, 213, 167)
$URL_Input = GUICtrlCreateInput("", 76, 8, 300, 21)
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj ($oIE, 8, 35, 583, 290)
GUISetState(@SW_SHOW)

While 1 ;Reloads every 5 minutes.
    _IENavigate ($oIE, "www.google.com")
    Sleep (300000)
    $msg = GUIGetMsg () 
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd

GUIDelete()
exit

It works well, but I can't close the browser because the script is infinite.

What should I do?

Link to comment
Share on other sites

I converted your script to OnEvent mode instead, it doesn't care what you do in your main loop :)

#include <GUIConstantsEx.au3>
#include <IE.au3>
Opt("GUIOnEventMode",1)
GUICreate("Browser", 601, 401, 213, 167)
GUISetOnEvent($GUI_EVENT_CLOSE,"close")
$URL_Input = GUICtrlCreateInput("", 76, 8, 300, 21)
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj ($oIE, 8, 35, 583, 290)
GUISetState(@SW_SHOW)

While 1;Reloads every 5 minutes.
    _IENavigate ($oIE, "www.google.com")
    Sleep (300000)
WEnd


Func close()
    Exit
EndFunc

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Now it's working...

But I have a bigger script and I don't know how to combine OnEventMode with my big script. Actually I don't sure that OnEventMode can be combined with my script, because there are negative things.

Link to comment
Share on other sites

Now it's working...

But I have a bigger script and I don't know how to combine OnEventMode with my big script. Actually I don't sure that OnEventMode can be combined with my script, because there are negative things.

It's of course easy to get your code working with GUIGetMsg() as well, but I really recommend you to use OnEvent because it's so much cleaner and you main loop doesn't get filled with a lot of sh*t.

#include <GUIConstants.au3>
#include <IE.au3>
AdlibEnable("_Reload", 300000)
GUICreate("Browser", 601, 401, 213, 167)
$URL_Input = GUICtrlCreateInput("", 76, 8, 300, 21)
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj ($oIE, 8, 35, 583, 290)
GUISetState(@SW_SHOW)
_IENavigate ($oIE, "www.google.com")
While 1;Reloads every 5 minutes.

    $msg = GUIGetMsg ()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd

GUIDelete()
exit

Func _Reload()
    _IENavigate ($oIE, "www.google.com")
EndFunc

:)

Oh and what are the negative aspects of OnEvent? So far I haven't found a single thing.

Broken link? PM me and I'll send you the file!

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