Jump to content
Sign in to follow this  
Sunblood

GUI Won't close when hitting the X

Recommended Posts

Sunblood

#include <IE.au3>
#include <Date.au3>
#Include <GuiListView.au3>
#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 2)
Opt("GUIOnEventMode", 1)

Global $pagetext, $ie, $ieactive, $hpnow, $hpmax, $turns
$ieactive = 0
$audrey = 0

GUICreate("Legend of LUEShi", 900, 150, 0, 0)
WinSetOnTop("Legend of LUEShi", "", 1)

$log = GUICtrlCreateListView("Time|Event", 5, 5, 400, 100)

$activate = GUICtrlCreateButton("Activate IE", 410, 5, 80)
$deactivate = GUICtrlCreateButton("Deactivate IE", 410, 30, 80)
GUICtrlSetState($deactivate, $GUI_DISABLE)
$hidden = GUICtrlCreateCheckbox("Start hidden", 410, 60)

GUICtrlCreateLabel("Next day:", 500, 5)
$newday = GUICtrlCreateInput("", 550, 3, 100)
$newdaybutton = GUICtrlCreateButton("?", 655, 3, -1, 22)
$newdaynotify = GUICtrlCreateCheckbox("Auto-Start", 680, 5)

$start = GUICtrlCreateButton("Start!", 500, 100, 200)

;Activate ()
;CopyPage ()

GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "Quit")
;GUICtrlSetOnEvent($newdaybutton, "GetNewDay")
GUICtrlSetOnEvent($activate, "Activate")
GUICtrlSetOnEvent($deactivate, "Deactivate")
;GUICtrlSetOnEvent($start, "Start")

GUISetState()
While 1
    If GUICtrlRead($newdaynotify) = $GUI_CHECKED And _NowCalc() = GUICtrlRead($newday) Then
        ;Start()
    EndIf
    Sleep(10)
WEnd

Func Quit()
    ;Deactivate()
    Exit
EndFunc   ;==>Quit
Func Activate()
    If $ieactive = 0 Then
        CreateIE(GUICtrlRead($hidden))
        GUICtrlSetState($deactivate, $GUI_ENABLE)
        GUICtrlSetState($activate, $GUI_DISABLE)
        AddLog("IE Active")
        $ieactive = 1
    EndIf
EndFunc   ;==>Activate
Func Deactivate()
    If $ieactive = 1 Then
        _IEQuit($ie)
        GUICtrlSetState($activate, $GUI_ENABLE)
        GUICtrlSetState($deactivate, $GUI_DISABLE)
        AddLog("IE Deactivated")
        $ieactive = 0
    EndIf
EndFunc   ;==>Deactivate

Func SendError($what, $message)
    AddLog($message)
EndFunc   ;==>SendError

Func AddLog($text)
    GUICtrlCreateListViewItem(@HOUR & ":" & @MIN & "|" & $text, $log)
    _GUICtrlListViewSetColumnWidth($log, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListViewScroll($log, 0, 999)
EndFunc   ;==>AddLog

Func CreateIE($visible = 0)
    If $visible = 1 Then $visible = 0
    If $visible = 4 Then $visible = 1
    $ie = _IECreate("www.lueshi.net", 1, $visible, 1)
    If @extended = 1 Then
        _IEAction($ie, "refresh")
    EndIf
EndFunc   ;==>CreateIE

Func FindInText($str, $exact = 0)
    ;GetPageText()
    For $i = 1 To $pagetext[0]
        If $exact = 0 Then
            If StringInStr($pagetext[$i], $str) Then
                Return $i
            EndIf
        Else
            If $pagetext[$i] = $str Then
                Return $i
            EndIf
        EndIf
    Next
    Return -1
EndFunc   ;==>FindInText

Func IESend($what)
    WinActivate("Windows Internet Explorer")
    ControlSend("Windows Internet Explorer", "", "Internet Explorer_Server1", $what)
    _IELoadWait($ie)
EndFunc   ;==>IESend

It seems to be set up correctly, but the event doesn't cause the Quit() function to be called at all.

Using the latest beta. The example script works perfectly.

Note that everything unnecessary has been removed/commented, and it still doesn't work properly.


Share this post


Link to post
Share on other sites
Danny35d

Change GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "Quit") for GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

Edit: I'm too slow writing... :P

Edited by Danny35d

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.