Jump to content
Sign in to follow this  
XinYoung

_IEAction "refresh" closes my GUI

Recommended Posts

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TXTechie
      Hello Everyone,
      I've developed my own GUI using AutoIt and I'm allowing users to minimize the GUI, but I also want to include some kind of timer so that it will automatically restore the GUI after something like 30 minutes or an hour. However, I also want them to be able to manually restore the GUI by clicking the application's icon in the taskbar.
      I've searched through the forums, but I'm not sure how to get started.
      Any ideas or functions to research are appreciated!
      Regards,
      TX Techie
    • By devilspride
      The following code creates a IE blank window
      Local $oIE = _IECreate()  
      But when i use Navigate to the URL, it open the URL in Microsoft Edge instead if IE.
      _IENavigate($oIE,$url)  
      What should i do to navigate in IE.
      Complete code :
      #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <IE.au3> #Region TESTING Local $url = 'https://www.youtube.com' Local $oIE = _IECreate() _IENavigate($oIE,$url) #EndRegion Console Output
      IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023174, Browser has been deleted prior to operation.)  
      I have searched the forums but did not find such kind of post.
      Other posts were describing How to use Edge using Web driver selenium.
       
      Edit: I am working in Windows10. Recently many changes have been done by Microsoft to IE and Microsoft Edge. (2020)
      Earlier in 2019 this was working fine.
    • By Rskm
      Hi, recently i created a GUI for some calculations in AutoIT.  The GUI has 2 tabs and on the first tab, it has few inputboxes where i use to click with mouse and start entering the inputs. i recently made some changes in the position of these textboxes. I made this by changing the autoit code file instead of making changes in KODA. Now i cannot click inside these textboxes with mouse. However, i can use TAB key to cycle through/enter input in these input boxes. what could have made the inputboxes not responding to mouseclicks. thanks
    • By Zaoka
      I'm trying to create script that would login on my SAP WEBI "web page" and replace some uploaded excel files. But i'm having problem on even the log in.
      These are user fill elements with Firefox Inspector
      <input type="text" id="_id0:logon:CMS" name="_id0:logon:CMS"> <input type="text" id="_id0:logon:USERNAME" name="_id0:logon:USERNAME"> <input type="password" id="_id0:logon:PASSWORD" name="_id0:logon:PASSWORD"> LogOnButton
      <input type="submit" id="_id0:logon:logonButton" value="Log On" class="logonButtonNoHover logon_button_no_hover" onmouseover="this.className = 'logonButtonHover logon_button_hover';" onmouseout="this.className = 'logonButtonNoHover logon_button_no_hover';">  
       
      My example, I tried _IEGetObjByName and _IEGetObjById but the script only open page but will not even fill out the form
        #include <IE.au3> Call("signIn") Func signIn() Global $oIE = _IECreate("http://192.xxx.xxx.xx:xxx/BOE/BI") Sleep (5000) Local $server = _IEGetObjByName($oIE, "_id0:logon:CMS") Local $username = _IEGetObjByName($oIE, "_id0:logon:USERNAME") Local $password = _IEGetObjByName($oIE, "_id0:logon:PASSWORD") Local $button = _IEGetObjById($oIE, "_id0:logon:logonButton") _IEFormElementSetValue($server, "TestServer:1000") _IEFormElementSetValue($username, "MyUserName") _IEFormElementSetValue($password, "MyPass") ; THIS PART ABOUT BUTTON CLICK I DONT UNDERSTAND AT ALL $sSelector = "body > div:nth-of-type(2) > div > div:nth-of-type(3) > div > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(1) > td > div > div:nth-of-type(1) > form > div:nth-of-type(5) > button" $signInUC = $oIE.document.QuerySelector($sSelector) _IEAction($signInUC, "click") EndFunc ;==>signIn  
      I would be very grateful for any help
    • By TheDcoder
      Hi everyone,
      I am bit stumped as to why I am not able to set the time in the Date control
      #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI get date", 200, 200, 800, 200) Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20, $DTS_TIMEFORMAT) ; to select a specific default format Local $sStyle = "HH:mm:ss" GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle) ; Set time Local $iRet = GUICtrlSetData($idDate, '13:33:37') ConsoleWrite('GUICtrlSetData returned ' & ($iRet = 1 ? 'success' : 'failure') & @CRLF) GUISetState(@SW_SHOW) ; Loop until the user exits. While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate)) EndFunc ;==>Example The documentation for GUICtrlSetData clearly mentions that it uses the same format as GUICtrlRead:
      But I get failure
      What gives?
      Thanks for the help in advance!
×
×
  • Create New...