Jump to content
Sign in to follow this  
XinYoung

_IEAction "refresh" closes my GUI

Recommended Posts

XinYoung

For fun, I'm building an app that opens a webpage and refreshes it every 30 seconds.

But once the script performs _IEAction($oIE, "refresh"), the GUI closes.

Any help is appreciated.

 


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>
#include <Array.au3>
#include <File.au3>
#include <Excel.au3>
#include <DateTimeConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>
#include <ComboConstants.au3>
#include <guimenu.au3>
#include <IE.au3>

HotKeySet("{F4}", "_Exit")

;Open the file(s) in the selected folder
$extension = ".txt"
$app2openWith = @SystemDir & "\notepad.exe"

Func Begin()

    Global $loopTrick = 0

    #Region ### START Koda GUI section ### Form=c:\users\mchu\downloads\autoit\my code\form1.kxf
    Global $UI = GUICreate("Hit Em Up!", 256, 113, -1, -1)
    GUISetBkColor(0x000000)

    $menu = _GUICtrlMenu_GetSystemMenu($UI)
    _GUICtrlMenu_EnableMenuItem($menu, $SC_CLOSE, 1, False)

    Global $url = GUICtrlCreateInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ", 81, 8, 160, 21)
    $Label1 = GUICtrlCreateLabel("Target:", 16, 8, 55, 17)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x00FF00)
    Global $StartBut = GUICtrlCreateButton("Start", 16, 40, 67, 25)
    GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x008000)
    $Label2 = GUICtrlCreateLabel("(Press F4 to Exit)", 96, 40, 8000, 17)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x00FF00)
    GUISetState(@SW_SHOW)

    #EndRegion ### END Koda GUI section ###

    While 1
        $UIfunc = GUIGetMsg()
        Select
            Case $UIfunc = $GUI_EVENT_CLOSE
                _Exit()
            Case $UIfunc = $StartBut
                If GUICtrlRead($url) = "" Then
                    MsgBox(48, "Um...", "Give me a target you idiot.")
                Else
                    GUICtrlSetState($url, $GUI_DISABLE)
                    GUICtrlSetState($StartBut, $GUI_DISABLE)
                    Start()
                EndIf
        EndSelect
    WEnd
EndFunc   ;==>Begin

Func Start()
    If $loopTrick = 0 Then
        Global $oIE = _IECreate(GUICtrlRead($url))
        _IELoadWait($oIE)
        Again()
    ElseIf $loopTrick = 1 Then
        Sleep(3000)
        _IEAction($oIE, "refresh")
        Sleep(3000)
        Start()
    EndIf
EndFunc   ;==>Start

Func Again()
    $loopTrick = 1
    Start()
EndFunc   ;==>Again

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Share this post


Link to post
Share on other sites
jdelaney

I bet you have some COM error, causing an exception in your script, causing it to terminate.

Add in a COM error handler.


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.

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  

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I have a goofy problem. I am hoping someone could shed some light. The example is not going around the text box. It is way off. 
      I have seen some post blaming IE 11, however I have IE11 on my desktop and it works fine.
      Is there anything I can do that might fix this? 
       
      ; Open a browser with the form example and get a reference to the form ; textarea element. Get the coordinates and dimensions of the text area, ; outline its shape with the mouse and come to rest in the center #include <IE.au3> Local $oIE = _IE_Example("form") Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm") Local $oTextArea = _IEFormElementGetObjByName($oForm, "textareaExample") ; Get coordinates and dimensions of the textarea Local $iScreenX = _IEPropertyGet($oTextArea, "screenx") Local $iScreenY = _IEPropertyGet($oTextArea, "screeny") Local $iWidth = _IEPropertyGet($oTextArea, "width") Local $iHeight = _IEPropertyGet($oTextArea, "height") ; Outline the textarea with the mouse, come to rest in the center Local $iMousespeed = 50 MouseMove($iScreenX, $iScreenY, $iMousespeed) MouseMove($iScreenX + $iWidth, $iScreenY, $iMousespeed) MouseMove($iScreenX + $iWidth, $iScreenY + $iHeight, $iMousespeed) MouseMove($iScreenX, $iScreenY + $iHeight, $iMousespeed) MouseMove($iScreenX, $iScreenY, $iMousespeed) MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed)  
       
    • nacerbaaziz
      By nacerbaaziz
      hi dears, i have an question please if you can help me.
      i maked an program to do some functions
      and this program works with the global hot keys
      i added an option to the users to change the hot keys
      when i searched about how to do that i found this UDF
      GUIHotkey.au3
      http://www.autoitscript.com/forum/index.php?showtopic=107965
      but the problem here that this UDF cant be detect the win key.
      can you help me to add it, or if there are any others UDFSS wich do that work please give me some.
      i hope that my question is clear for you.
      thanks in advance
    • Silas
      By Silas
      Hello everyone,
      I have a radio button ($Radio1), which I want to disable as soon as another one get's checked (Radio5). (The system fails if the radio button i'm troubling with also gets checked).
      I know how to disable him:
      If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_DISABLE) Then GUICtrlSetState($Radio5, 128) But if i try to enable $Radio5 again, after $Radio1 isn't checked anymore, it fails:
      If GUICtrlRead($Radio1)=Not 1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_ENABLE) Then GUICtrlSetState($Radio5, 64)  
      Anyone knows why?
    • iamtech
      By iamtech
      i tried to print ie windows with my default printer  using
      _IEAction ($oIE, "printdefault") but it was not working sometimes, autoit icon showing in tray but not printing anything.
    • SkysLastChance
      By SkysLastChance
      So I have two things I am trying to click.
      Policy which works.
      $oInputs3 = _IETagNameGetCollection($oIE, "div") For $oInput3 in $oInputs3 If StringStripWS($oInput3.innertext,1) = "Policy" Then $target = $oInput3 _IELoadWait($target,"",70000) ExitLoop EndIf Next _IEAction($target, "click")  

      And Add Insurance which I havent been able to get to work. 
      $oInputs2 = _IETagNameGetCollection($oIE, "div") For $oInput2 in $oInputs2 If StringStripWS($oInput2.innertext,1) = "Add Insurance" Then $target = $oInput2 _IELoadWait($target,"",70000) ExitLoop EndIf Next _IEAction($target, "click")

      Any Ideas on what I am doing wrong?  I feel like it might be the spaces between >  Add Insurance  < but I am not sure. 
×