Jump to content

Recommended Posts

Posted

Hello. This problem is puzzling me. $Button3 should close the current GUI and open the Main_Form(). It works fine if I just run the program and toggle back-and-forth. However, if I write in $Input1 at all, then hit $Button3 my Main_Form GUI opens but $Form2 does not close. I have tried writing "" to the input box once the 'ADD' button is clicked and I have tried GUICtrlGetHandle as part of the GUIDelete command, neither made a difference. As I said, it works fine unless I write in $Input1. Weird! Any help would be appraciated. Here is the function I am working on:

Func URL_Config()

    Local $oFile = @ScriptDir & "\URL_List.txt"
    FileOpen($oFile, 0)

    ; Check if file opened for reading OK
    If $oFile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    #Region ### START Koda GUI section ### Form=C:\Users\elahr.VITACOST\Documents\AutoIT Scripts\Form2.kxf
    $Form2 = GUICreate("Add or Remove URL", 543, 671, 250, 14)
    $List1 = GUICtrlCreateList("", 24, 40, 497, 344)
    $Label1 = GUICtrlCreateLabel("Select URL to Remove", 0, 8, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Remove", 40, 392, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 24, 504, 497, 21)
    $Label2 = GUICtrlCreateLabel("Enter URL to Add", 0, 472, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Add", 43, 532, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Return to Display Setup", 39, 610, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###



    For $i = 1 to _FileCountLines($oFile)
            $line = FileReadLine($oFile,$i)
            GUICtrlSetData($List1, $line)
    Next

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                $select = GUICtrlRead($List1)
                For $i = 1 to _FileCountLines($oFile)
                    $line = FileReadLine($oFile,$i)
                    If $line = $select Then
                        _FileWriteToLine($oFile, $i, "", True)
                        _GUICtrlListBox_ResetContent($List1)
                        For $z = 1 to _FileCountLines($oFile)
                            $oLine = FileReadLine($oFile,$z)
                            GUICtrlSetData($List1, $oLine)
                        Next
                        ExitLoop
                    EndIf
                Next
            Case $Button2
                $new = GUICtrlRead($Input1)
                GUICtrlSetData($Input1, "")
                ;MsgBox(0, "", "Input: " & $new)
                If $new <> "" Then FileWriteLine($oFile, $new)
                    _GUICtrlListBox_ResetContent($List1)
                    For $z = 1 to _FileCountLines($oFile)
                            $oLine = FileReadLine($oFile,$z)
                            GUICtrlSetData($List1, $oLine)
                    Next
                If $new = "" Then MsgBox(0, "Error", "There is nothing to add.")
                    URL_Config()
            Case $Button3
                GUIDelete(GUICtrlGetHandle($Form2))
                Main_Form()

        EndSwitch
    WEnd

EndFunc

 

Posted

Thanks for the reply! Actually, that is how I had it first. I made the change to use the GetHandle command to try to fix the problem but it made no difference. I will change it back but the problem remains. I have also tried using the $Form2 title "Add or Remove URL" which made no difference. As I said, it works fine if I don't type in $Input1. So weird.

Posted

Sorry. I will post the whole thing. It is pretty long. Here you go:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <GUIListBox.au3>

Main_Form()

Func Main_Form()

    #Region ### START Koda GUI section ### Form=c:\users\elahr.vitacost\documents\autoit scripts\form1.kxf
    $Form1 = GUICreate("", 798, 401, 177, 114)
    $Label1 = GUICtrlCreateLabel("Display Request Form", 0, 8, 715, 41, $SS_CENTER)
    GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("0", 416, 120, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
    $Combo1 = GUICtrlCreateCombo("", 16, 120, 385, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo2 = GUICtrlCreateCombo("", 16, 152, 385, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo3 = GUICtrlCreateCombo("", 16, 184, 385, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo4 = GUICtrlCreateCombo("", 16, 216, 385, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo5 = GUICtrlCreateCombo("", 16, 248, 385, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Input2 = GUICtrlCreateInput("0", 416, 152, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
    $Label2 = GUICtrlCreateLabel("URL to Display", 120, 80, 139, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Minutes", 417, 82, 77, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("0", 416, 184, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
    $Input4 = GUICtrlCreateInput("0", 416, 216, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
    $Input5 = GUICtrlCreateInput("0", 416, 248, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
    $Button1 = GUICtrlCreateButton("Open Page and Configure", 645, 120, 139, 17)
    $Button2 = GUICtrlCreateButton("Begin Display", 168, 293, 355, 33)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Add or Remove URL", 205, 347, 291, 33)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button4 = GUICtrlCreateButton("Open Page and Configure", 645, 153, 139, 17)
    $Button5 = GUICtrlCreateButton("Open Page and Configure", 645, 187, 139, 17)
    $Button6 = GUICtrlCreateButton("Open Page and Configure", 645, 217, 139, 17)
    $Button7 = GUICtrlCreateButton("Open Page and Configure", 645, 251, 139, 17)
    $Label4 = GUICtrlCreateLabel("Refresh", 536, 80, 76, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Radio1 = GUICtrlCreateRadio("", 566, 120, 17, 17)
    $Radio2 = GUICtrlCreateRadio("", 566, 152, 17, 17)
    $Radio3 = GUICtrlCreateRadio("", 566, 184, 17, 17)
    $Radio4 = GUICtrlCreateRadio("", 566, 217, 17, 17)
    $Radio5 = GUICtrlCreateRadio("", 566, 250, 17, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    Local $oFile = @ScriptDir & "\URL_List.txt"
    FileOpen($oFile, 0)

    ; Check if file opened for reading OK
    If $oFile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    For $ii = 1 to 5
        ; Read in lines of text until the EOF is reached
        For $i = 1 to _FileCountLines($oFile)
            $line = FileReadLine($oFile,$i)
            ;MsgBox(0,'',$line)
            If $ii = 1 Then GUICtrlSetData($Combo1, $line)
            If $ii = 2 Then GUICtrlSetData($Combo2, $line)
            If $ii = 3 Then GUICtrlSetData($Combo3, $line)
            If $ii = 4 Then GUICtrlSetData($Combo4, $line)
            If $ii = 5 Then GUICtrlSetData($Combo5, $line)

        Next
    Next

    FileClose($oFile)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button3
                GUIDelete($Form1)
                URL_Config()

        EndSwitch
    WEnd

EndFunc

Func URL_Config()

    Local $oFile = @ScriptDir & "\URL_List.txt"
    FileOpen($oFile, 0)

    ; Check if file opened for reading OK
    If $oFile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    #Region ### START Koda GUI section ### Form=C:\Users\elahr.VITACOST\Documents\AutoIT Scripts\Form2.kxf
    $Form2 = GUICreate("Add or Remove URL", 543, 671, 250, 14)
    $List1 = GUICtrlCreateList("", 24, 40, 497, 344)
    $Label1 = GUICtrlCreateLabel("Select URL to Remove", 0, 8, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Remove", 40, 392, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 24, 504, 497, 21)
    $Label2 = GUICtrlCreateLabel("Enter URL to Add", 0, 472, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Add", 43, 532, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Return to Display Setup", 39, 610, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###



    For $i = 1 to _FileCountLines($oFile)
            $line = FileReadLine($oFile,$i)
            GUICtrlSetData($List1, $line)
    Next

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                $select = GUICtrlRead($List1)
                For $i = 1 to _FileCountLines($oFile)
                    $line = FileReadLine($oFile,$i)
                    If $line = $select Then
                        _FileWriteToLine($oFile, $i, "", True)
                        _GUICtrlListBox_ResetContent($List1)
                        For $z = 1 to _FileCountLines($oFile)
                            $oLine = FileReadLine($oFile,$z)
                            GUICtrlSetData($List1, $oLine)
                        Next
                        ExitLoop
                    EndIf
                Next
            Case $Button2
                $new = GUICtrlRead($Input1)
                GUICtrlSetData($Input1, "")
                ;MsgBox(0, "", "Input: " & $new)
                If $new <> "" Then FileWriteLine($oFile, $new)
                    _GUICtrlListBox_ResetContent($List1)
                    For $z = 1 to _FileCountLines($oFile)
                            $oLine = FileReadLine($oFile,$z)
                            GUICtrlSetData($List1, $oLine)
                    Next
                If $new = "" Then MsgBox(0, "Error", "There is nothing to add.")
                    URL_Config()
            Case $Button3
                GUIDelete($Form2)
                Main_Form()

        EndSwitch
    WEnd

EndFunc

 

Posted

Try this, and if it's not working correctly, please let us know exactly how it's not working correctly.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <GUIListBox.au3>

Main_Form()

Func Main_Form()

    #Region ### START Koda GUI section ### Form=c:\users\elahr.vitacost\documents\autoit scripts\form1.kxf
    $Form1 = GUICreate("", 798, 401, 177, 114)
    $Label1 = GUICtrlCreateLabel("Display Request Form", 0, 8, 715, 41, $SS_CENTER)
    GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("0", 416, 120, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Combo1 = GUICtrlCreateCombo("", 16, 120, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo2 = GUICtrlCreateCombo("", 16, 152, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo3 = GUICtrlCreateCombo("", 16, 184, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo4 = GUICtrlCreateCombo("", 16, 216, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo5 = GUICtrlCreateCombo("", 16, 248, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Input2 = GUICtrlCreateInput("0", 416, 152, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Label2 = GUICtrlCreateLabel("URL to Display", 120, 80, 139, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Minutes", 417, 82, 77, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("0", 416, 184, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Input4 = GUICtrlCreateInput("0", 416, 216, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Input5 = GUICtrlCreateInput("0", 416, 248, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Button1 = GUICtrlCreateButton("Open Page and Configure", 645, 120, 139, 17)
    $Button2 = GUICtrlCreateButton("Begin Display", 168, 293, 355, 33)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Add or Remove URL", 205, 347, 291, 33)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button4 = GUICtrlCreateButton("Open Page and Configure", 645, 153, 139, 17)
    $Button5 = GUICtrlCreateButton("Open Page and Configure", 645, 187, 139, 17)
    $Button6 = GUICtrlCreateButton("Open Page and Configure", 645, 217, 139, 17)
    $Button7 = GUICtrlCreateButton("Open Page and Configure", 645, 251, 139, 17)
    $Label4 = GUICtrlCreateLabel("Refresh", 536, 80, 76, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Radio1 = GUICtrlCreateRadio("", 566, 120, 17, 17)
    $Radio2 = GUICtrlCreateRadio("", 566, 152, 17, 17)
    $Radio3 = GUICtrlCreateRadio("", 566, 184, 17, 17)
    $Radio4 = GUICtrlCreateRadio("", 566, 217, 17, 17)
    $Radio5 = GUICtrlCreateRadio("", 566, 250, 17, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    Local $oFile = @ScriptDir & "\URL_List.txt"
    FileOpen($oFile, 0)

    ; Check if file opened for reading OK
    If $oFile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    For $ii = 1 To 5
        ; Read in lines of text until the EOF is reached
        For $i = 1 To _FileCountLines($oFile)
            $line = FileReadLine($oFile, $i)
            ;MsgBox(0,'',$line)
            If $ii = 1 Then GUICtrlSetData($Combo1, $line)
            If $ii = 2 Then GUICtrlSetData($Combo2, $line)
            If $ii = 3 Then GUICtrlSetData($Combo3, $line)
            If $ii = 4 Then GUICtrlSetData($Combo4, $line)
            If $ii = 5 Then GUICtrlSetData($Combo5, $line)

        Next
    Next

    FileClose($oFile)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button3
;~              GUIDelete($Form1) <<<<<<<<<<<<<< Not needed, unless you want to have to readd everything all of the time
;~                                               You can hide it if you need to make it not visible while using Form2
                URL_Config()

        EndSwitch
    WEnd

EndFunc   ;==>Main_Form

Func URL_Config()

    Local $oFile = @ScriptDir & "\URL_List.txt"
    FileOpen($oFile, 0)

    ; Check if file opened for reading OK
    If $oFile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    #Region ### START Koda GUI section ### Form=C:\Users\elahr.VITACOST\Documents\AutoIT Scripts\Form2.kxf
    $Form2 = GUICreate("Add or Remove URL", 543, 671, 250, 14)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Form2 = ' & $Form2 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $List1 = GUICtrlCreateList("", 24, 40, 497, 344)
    $Label1 = GUICtrlCreateLabel("Select URL to Remove", 0, 8, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Remove", 40, 392, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 24, 504, 497, 21)
    $Label2 = GUICtrlCreateLabel("Enter URL to Add", 0, 472, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Add", 43, 532, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Return to Display Setup", 39, 610, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###



    For $i = 1 To _FileCountLines($oFile)
        $line = FileReadLine($oFile, $i)
        GUICtrlSetData($List1, $line)
    Next

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
;~          Case $GUI_EVENT_CLOSE
;~              Exit
            Case $Button1
                $select = GUICtrlRead($List1)
                For $i = 1 To _FileCountLines($oFile)
                    $line = FileReadLine($oFile, $i)
                    If $line = $select Then
                        _FileWriteToLine($oFile, $i, "", True)
                        _GUICtrlListBox_ResetContent($List1)
                        For $z = 1 To _FileCountLines($oFile)
                            $oLine = FileReadLine($oFile, $z)
                            GUICtrlSetData($List1, $oLine)
                        Next
                        ExitLoop
                    EndIf
                Next
            Case $Button2
                $new = GUICtrlRead($Input1)
                GUICtrlSetData($Input1, "")
                ;MsgBox(0, "", "Input: " & $new)
                If $new <> "" Then FileWriteLine($oFile, $new)
                _GUICtrlListBox_ResetContent($List1)
                For $z = 1 To _FileCountLines($oFile)
                    $oLine = FileReadLine($oFile, $z)
                    GUICtrlSetData($List1, $oLine)
                Next
                If $new = "" Then MsgBox(0, "Error", "There is nothing to add.")
;~                   URL_Config() <<<<<<<<<<<<<<<<<<< Recursing the function
            Case $Button3, $GUI_EVENT_CLOSE
                GUIDelete($Form2)
;~                 Main_Form() <<<<<<<<<<<<<<<<< Recursing the first function
                Return
        EndSwitch
    WEnd

EndFunc   ;==>URL_Config

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Thanks for the help. BrewManNH, I added $GUI_EVENT_CLOSE to my $Button3 code on $Form2 as you suggested. It made no change for me. I posted because I thought this would be a known bug. I figured this had to have come up before or I am doing something very wrong. I can easily toggle between both forms: start program, click $Button3 on $Form1, it disappears and $Form2 is presented, click $Button3 on $Form2, it disappears and $Form1 is presented all as expected.

However, if I type anything into $Input1 on $Form2 and use the 'Add' button ($Button2) to add the typed text to the listbox, when I use $Button3 on $Form2 to toggle back to $Form1, $Form1 appears as before with focus but $Form2 remains and does not disappear until I close the whole program. Small thing but it would be much cleaner if it worked. Very strange. Thanks again for your valuable input!

 

Posted
26 minutes ago, tuffgong said:

click $Button3 on $Form1, it disappears

No, you delete it in your original code.

27 minutes ago, tuffgong said:

$Form2 remains and does not disappear

With the changes I made it closes.

 

Try this updated version, should work better.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <GUIListBox.au3>

Main_Form()

Func Main_Form()

    #Region ### START Koda GUI section ### Form=c:\users\elahr.vitacost\documents\autoit scripts\form1.kxf
    $Form1 = GUICreate("", 798, 401, 177, 114)
    $Label1 = GUICtrlCreateLabel("Display Request Form", 0, 8, 715, 41, $SS_CENTER)
    GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("0", 416, 120, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Combo1 = GUICtrlCreateCombo("", 16, 120, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo2 = GUICtrlCreateCombo("", 16, 152, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo3 = GUICtrlCreateCombo("", 16, 184, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo4 = GUICtrlCreateCombo("", 16, 216, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo5 = GUICtrlCreateCombo("", 16, 248, 385, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Input2 = GUICtrlCreateInput("0", 416, 152, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Label2 = GUICtrlCreateLabel("URL to Display", 120, 80, 139, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Minutes", 417, 82, 77, 28, $SS_CENTER)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("0", 416, 184, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Input4 = GUICtrlCreateInput("0", 416, 216, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Input5 = GUICtrlCreateInput("0", 416, 248, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    $Button1 = GUICtrlCreateButton("Open Page and Configure", 645, 120, 139, 17)
    $Button2 = GUICtrlCreateButton("Begin Display", 168, 293, 355, 33)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Add or Remove URL", 205, 347, 291, 33)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button4 = GUICtrlCreateButton("Open Page and Configure", 645, 153, 139, 17)
    $Button5 = GUICtrlCreateButton("Open Page and Configure", 645, 187, 139, 17)
    $Button6 = GUICtrlCreateButton("Open Page and Configure", 645, 217, 139, 17)
    $Button7 = GUICtrlCreateButton("Open Page and Configure", 645, 251, 139, 17)
    $Label4 = GUICtrlCreateLabel("Refresh", 536, 80, 76, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Radio1 = GUICtrlCreateRadio("", 566, 120, 17, 17)
    $Radio2 = GUICtrlCreateRadio("", 566, 152, 17, 17)
    $Radio3 = GUICtrlCreateRadio("", 566, 184, 17, 17)
    $Radio4 = GUICtrlCreateRadio("", 566, 217, 17, 17)
    $Radio5 = GUICtrlCreateRadio("", 566, 250, 17, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    Local $oFile = @ScriptDir & "\URL_List.txt"
    $file = FileOpen($oFile, 0)

    ; Check if file opened for reading OK
    If $oFile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    While 1
        $line = FileReadLine($file)
        If @error = -1 Then ExitLoop
        GUICtrlSetData($Combo1, $line)
        GUICtrlSetData($Combo2, $line)
        GUICtrlSetData($Combo3, $line)
        GUICtrlSetData($Combo4, $line)
        GUICtrlSetData($Combo5, $line)
    WEnd

    FileClose($oFile)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button3
;~              GUIDelete($Form1) <<<<<<<<<<<<<< Not needed, unless you want to have to readd everything all of the time
;~                                               You can hide it if you need to make it not visible while using Form2
                GUISetState(@SW_HIDE, $Form1)
                URL_Config()
                $file = FileOpen($oFile, 0)
                ; Read in lines of text until the EOF is reached
                While 1
                    $line = FileReadLine($file)
                    If @error = -1 Then ExitLoop
                    GUICtrlSetData($Combo1, $line)
                    GUICtrlSetData($Combo2, $line)
                    GUICtrlSetData($Combo3, $line)
                    GUICtrlSetData($Combo4, $line)
                    GUICtrlSetData($Combo5, $line)
                WEnd
                FileClose($oFile)
                GUISetState(@SW_SHOW, $Form1)
        EndSwitch
    WEnd

EndFunc   ;==>Main_Form

Func URL_Config()
    Local $oFile = @ScriptDir & "\URL_List.txt"
    FileOpen($oFile, 0)

    ; Check if file opened for reading OK
    If $oFile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf

    #Region ### START Koda GUI section ### Form=C:\Users\elahr.VITACOST\Documents\AutoIT Scripts\Form2.kxf
    $Form2 = GUICreate("Add or Remove URL", 543, 671, 250, 14)
    $List1 = GUICtrlCreateList("", 24, 40, 497, 344)
    $Label1 = GUICtrlCreateLabel("Select URL to Remove", 0, 8, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Remove", 40, 392, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 24, 504, 497, 21)
    $Label2 = GUICtrlCreateLabel("Enter URL to Add", 0, 472, 539, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Add", 43, 532, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Return to Display Setup", 39, 610, 465, 33)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###



    For $i = 1 To _FileCountLines($oFile)
        $line = FileReadLine($oFile, $i)
        GUICtrlSetData($List1, $line)
    Next

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
;~          Case $GUI_EVENT_CLOSE
;~              Exit
            Case $Button1
                $select = GUICtrlRead($List1)
                For $i = 1 To _FileCountLines($oFile)
                    $line = FileReadLine($oFile, $i)
                    If $line = $select Then
                        _FileWriteToLine($oFile, $i, "", True)
                        _GUICtrlListBox_ResetContent($List1)
                        For $z = 1 To _FileCountLines($oFile)
                            $oLine = FileReadLine($oFile, $z)
                            GUICtrlSetData($List1, $oLine)
                        Next
                        ExitLoop
                    EndIf
                Next
            Case $Button2
                $new = GUICtrlRead($Input1)
                GUICtrlSetData($Input1, "")
                ;MsgBox(0, "", "Input: " & $new)
                If $new <> "" Then FileWriteLine($oFile, $new)
                _GUICtrlListBox_ResetContent($List1)
                For $z = 1 To _FileCountLines($oFile)
                    $oLine = FileReadLine($oFile, $z)
                    GUICtrlSetData($List1, $oLine)
                Next
                If $new = "" Then MsgBox(0, "Error", "There is nothing to add.")
;~                   URL_Config() <<<<<<<<<<<<<<<<<<< Recursing the function
            Case $Button3, $GUI_EVENT_CLOSE
                GUIDelete($Form2)
;~                 Main_Form() <<<<<<<<<<<<<<<<< Recursing the first function
                Return
        EndSwitch
    WEnd

EndFunc   ;==>URL_Config

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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
×
×
  • Create New...