Jump to content
Sign in to follow this  
Arclite86

How To Put A Function After If,Then

Recommended Posts

For example If I want to click the "Next" button

$_FF_COM_TRACE = True
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
;#include <FF.au3>
#include <staticConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <Excel.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
Local $oIE
;, BitOR($WS_BORDER, $WS_VSCROLL)

;_FFStart( "https://www.google.nl" )
;WinSetState ( "Google - Mozilla Firefox", "", @SW_MINIMIZE )








;~ _GUIExtender_Init($Form1_1_1_1)

For $i = 1 To 13
FileDelete(@ScriptDir & "\list" & $i & ".txt")
FileWrite(@ScriptDir & "\list" & $i & ".txt", "text " & $i)
Next

Global $iIndex = 0
#Region ### START Koda GUI section ### Form=
$Form1_1_1_1 = GUICreate("program", 814, 713, 697, 101)
$List1 = GUICtrlCreateList("", 0, 64, 145, 358)
GUICtrlSetData(-1, "")
$List2 = GUICtrlCreateList("", 144, 64, 65, 358)
GUICtrlSetData(-1, "")
$List3 = GUICtrlCreateList("", 208, 64, 65, 358)
GUICtrlSetData(-1, "")
$List4 = GUICtrlCreateList("", 344, 64, 153, 358)
GUICtrlSetData(-1, "")
$List5 = GUICtrlCreateList("", 496, 64, 65, 358)
GUICtrlSetData(-1, "")
$List6 = GUICtrlCreateList("", 560, 64, 121, 230)
GUICtrlSetData(-1, "")
$List7 = GUICtrlCreateList("", 680, 64, 65, 230)
GUICtrlSetData(-1, "")
$List8 = GUICtrlCreateList("", 744, 64, 65, 230)
GUICtrlSetData(-1, "")
$List9 = GUICtrlCreateList("", 272, 64, 65, 358)
GUICtrlSetData(-1, "")

GUISetState(@SW_SHOW)

Local $helpmenu, $infoitem, $exititem, $recentfilesmenu
Local $viewmenu, $viewstatusitem
Local $statuslabel, $msg, $file



$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$newitem = GUICtrlCreateMenuItem("new", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
GUICtrlCreateMenuItem("Save", $filemenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("Info", $helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1)

GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)
$message4 = GUICtrlCreateMenuItem("message", $filemenu)


$Button1 = GUICtrlCreateButton("Next", 208, 0, 41, 25)

GUICtrlSetState(-1, $GUI_FOCUS)




GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1

$msg = GUIGetMsg()

If $msg = $fileitem Then
ConsoleWrite("Hit" & @CRLF)

$file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
If @error <> 1 Then
GUICtrlCreateMenuItem($file, $recentfilesmenu)
_FillLists($file)
EndIf
EndIf
if $msg = $newitem Then
$newitem = FileSaveDialog("Choose file...", @TempDir, "All (*.*)")
_Example($newitem)
EndIf
If $msg = $viewstatusitem Then
If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)
GUICtrlSetState($statuslabel, $GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem, $GUI_CHECKED)
GUICtrlSetState($statuslabel, $GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then ExitLoop


If $msg = $infoitem Then MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")



WEnd
GUIDelete()

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

Func _FillLists($file)


Local $newfile = StringReplace($file, "Openfile.txt", "")

$1newfile = ($newfile & ("lists\list"))


Global $iIndex = 0, $sListData1 = ($1newfile & ("1.txt"))
Global $sListFile1 = ($1newfile & ("1.txt"))

Global $iIndex = 0, $sListData2 = ($1newfile & ("2.txt"))
Global $sListFile2 = ($1newfile & ("2.txt"))

Global $iIndex = 0, $sListData3 = ($1newfile & ("3.txt"))
Global $sListFile3 = ($1newfile & ("3.txt"))

Global $iIndex = 0, $sListData4 = ($1newfile & ("4.txt"))
Global $sListFile4 = ($1newfile & ("4.txt"))

Global $iIndex = 0, $sListData5 = ($1newfile & ("5.txt"))
Global $sListFile5 = ($1newfile & ("5.txt"))

Global $iIndex = 0, $sListData6 = ($1newfile & ("6.txt"))
Global $sListFile6 = ($1newfile & ("6.txt"))

Global $iIndex = 0, $sListData7 = ($1newfile & ("7.txt"))
Global $sListFile7 = ($1newfile & ("7.txt"))

Global $iIndex = 0, $sListData8 = ($1newfile & ("8.txt"))
Global $sListFile8 = ($1newfile & ("8.txt"))

Global $iIndex = 0, $sListData9 = ($1newfile & ("9.txt"))
Global $sListFile9 = ($1newfile & ("9.txt"))

Global $iIndex = 0, $sListData10 = ($1newfile & ("10.txt"))
Global $sListFile10 = ($1newfile & ("10.txt"))

Global $iIndex = 0, $sListData11 = ($1newfile & ("11.txt"))
Global $sListFile11 = ($1newfile & ("11.txt"))

Global $iIndex = 0, $sListData12 = ($1newfile & ("12.txt"))
Global $sListFile12 = ($1newfile & ("12.txt"))

Global $iIndex = 0, $sListData13 = ($1newfile & ("13.txt"))
Global $sListFile13 = ($1newfile & ("13.txt"))







; Read saved file if it exists--------
If FileExists($sListFile1) Then
$sListData1 = FileRead($sListFile1)
Else
MsgBox($MB_SYSTEMMODAL, "Error", $sListFile1 & " does not exist") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndIf

; Load data read from the file
GUICtrlSetData($List1, $sListData1)
_GUICtrlListBox_SetCurSel($List1, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile2) Then
$sListData2 = FileRead($sListFile2)
EndIf




; Load data read from the file
GUICtrlSetData($List2, $sListData2)
_GUICtrlListBox_SetCurSel($List2, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile3) Then
$sListData3 = FileRead($sListFile3)
EndIf




; Load data read from the file
GUICtrlSetData($List3, $sListData3)
_GUICtrlListBox_SetCurSel($List3, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile4) Then
$sListData4 = FileRead($sListFile4)
EndIf




; Load data read from the file
GUICtrlSetData($List4, $sListData4)
_GUICtrlListBox_SetCurSel($List4, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile5) Then
$sListData5 = FileRead($sListFile5)
EndIf



; Load data read from the file
GUICtrlSetData($List5, $sListData5)
_GUICtrlListBox_SetCurSel($List5, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile6) Then
$sListData6 = FileRead($sListFile6)
EndIf

; Load data read from the file
GUICtrlSetData($List6, $sListData6)
_GUICtrlListBox_SetCurSel($List6, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile7) Then
$sListData7 = FileRead($sListFile7)
EndIf

; Load data read from the file
GUICtrlSetData($List7, $sListData7)
_GUICtrlListBox_SetCurSel($List7, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile8) Then
$sListData8 = FileRead($sListFile8)
EndIf

; Load data read from the file
GUICtrlSetData($List8, $sListData8)
_GUICtrlListBox_SetCurSel($List8, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile9) Then
$sListData9 = FileRead($sListFile9)
EndIf

; Load data read from the file
GUICtrlSetData($List9, $sListData9)
_GUICtrlListBox_SetCurSel($List9, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile10) Then
$sListData10 = FileRead($sListFile10)
EndIf

EndFunc




Func _Example($newitem )
    ; Create a constant variable in Local scope of the message to display in FileSaveDialog.
    Local Const $sMessage = "Choose a filename."

    ; Display a save dialog to select a file.
    Local $sFileSaveDialog = FileSaveDialog($sMessage, "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Scripts (*.au3)", $FD_PATHMUSTEXIST)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file was saved.")
    Else
        ; Retrieve the filename from the filepath e.g. Example.au3.
        Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSE, -1))

        ; Check if the extension .au3 is appended to the end of the filename.
        Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSE)

        ; If a period (dot) is found then check whether or not the extension is equal to .au3.
        If $iExtension Then
            ; If the extension isn't equal to .au3 then append to the end of the filepath.
            If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".au3") Then $sFileSaveDialog &= ".au3"
        Else
            ; If no period (dot) was found then append to the end of the file.
            $sFileSaveDialog &= ".au3"
        EndIf

        ; Display the saved file.
        MsgBox($MB_SYSTEMMODAL, "", "You saved the following file:" & @CRLF & $sFileSaveDialog)
    EndIf
EndFunc   ;==>Example



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Button1

            $iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)






            If $iIndex = _GUICtrlListBox_GetCount($List4) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List4, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List2) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List2, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List3) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List3, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List9) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List9, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List5) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List5, $iIndex)






    EndSwitch
WEnd
Edited by Arclite86

Share this post


Link to post
Share on other sites

Reading code without appropriate indentation is a bugger.

The code you have is also confusing, and I see you create your NEXT button as $Button1, but don't have it in your main GUI, only listed in the _Example() function. It needs to reside in your GUI code. What you wish to achieve with it I haven't yet perceived.

You really need to Tidy your code.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

sorry the  _example() function was just a test but I removed now and placed the $button1 in the GUI (above the lists).

But its stil not working

$_FF_COM_TRACE = True
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
;#include <FF.au3>
#include <staticConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <Excel.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
Local $oIE
;, BitOR($WS_BORDER, $WS_VSCROLL)

;_FFStart( "https://www.google.nl" )
;WinSetState ( "Google - Mozilla Firefox", "", @SW_MINIMIZE )








;~ _GUIExtender_Init($Form1_1_1_1)

For $i = 1 To 13
FileDelete(@ScriptDir & "\list" & $i & ".txt")
FileWrite(@ScriptDir & "\list" & $i & ".txt", "text " & $i)
Next

Global $iIndex = 0
#Region ### START Koda GUI section ### Form=
$Form1_1_1_1 = GUICreate("program", 814, 713, 697, 101)
$Button1 = GUICtrlCreateButton("Next", 208, 0, 41, 25)
$List1 = GUICtrlCreateList("", 0, 64, 145, 358)
GUICtrlSetData(-1, "")
$List2 = GUICtrlCreateList("", 144, 64, 65, 358)
GUICtrlSetData(-1, "")
$List3 = GUICtrlCreateList("", 208, 64, 65, 358)
GUICtrlSetData(-1, "")
$List4 = GUICtrlCreateList("", 344, 64, 153, 358)
GUICtrlSetData(-1, "")
$List5 = GUICtrlCreateList("", 496, 64, 65, 358)
GUICtrlSetData(-1, "")
$List6 = GUICtrlCreateList("", 560, 64, 121, 230)
GUICtrlSetData(-1, "")
$List7 = GUICtrlCreateList("", 680, 64, 65, 230)
GUICtrlSetData(-1, "")
$List8 = GUICtrlCreateList("", 744, 64, 65, 230)
GUICtrlSetData(-1, "")
$List9 = GUICtrlCreateList("", 272, 64, 65, 358)
GUICtrlSetData(-1, "")

GUISetState(@SW_SHOW)

Local $helpmenu, $infoitem, $exititem, $recentfilesmenu
Local $viewmenu, $viewstatusitem
Local $statuslabel, $msg, $file



$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$newitem = GUICtrlCreateMenuItem("new", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
GUICtrlCreateMenuItem("Save", $filemenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("Info", $helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1)

GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)
$message4 = GUICtrlCreateMenuItem("message", $filemenu)




GUICtrlSetState(-1, $GUI_FOCUS)




GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1

$msg = GUIGetMsg()

If $msg = $fileitem Then
ConsoleWrite("Hit" & @CRLF)

$file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
If @error <> 1 Then
GUICtrlCreateMenuItem($file, $recentfilesmenu)
_FillLists($file)
EndIf
EndIf
if $msg = $newitem Then
$newitem = FileSaveDialog("Choose file...", @TempDir, "All (*.*)")

EndIf
If $msg = $viewstatusitem Then
If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)
GUICtrlSetState($statuslabel, $GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem, $GUI_CHECKED)
GUICtrlSetState($statuslabel, $GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then ExitLoop


If $msg = $infoitem Then MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")



WEnd
GUIDelete()

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

Func _FillLists($file)


Local $newfile = StringReplace($file, "Openfile.txt", "")

$1newfile = ($newfile & ("lists\list"))


Global $iIndex = 0, $sListData1 = ($1newfile & ("1.txt"))
Global $sListFile1 = ($1newfile & ("1.txt"))

Global $iIndex = 0, $sListData2 = ($1newfile & ("2.txt"))
Global $sListFile2 = ($1newfile & ("2.txt"))

Global $iIndex = 0, $sListData3 = ($1newfile & ("3.txt"))
Global $sListFile3 = ($1newfile & ("3.txt"))

Global $iIndex = 0, $sListData4 = ($1newfile & ("4.txt"))
Global $sListFile4 = ($1newfile & ("4.txt"))

Global $iIndex = 0, $sListData5 = ($1newfile & ("5.txt"))
Global $sListFile5 = ($1newfile & ("5.txt"))

Global $iIndex = 0, $sListData6 = ($1newfile & ("6.txt"))
Global $sListFile6 = ($1newfile & ("6.txt"))

Global $iIndex = 0, $sListData7 = ($1newfile & ("7.txt"))
Global $sListFile7 = ($1newfile & ("7.txt"))

Global $iIndex = 0, $sListData8 = ($1newfile & ("8.txt"))
Global $sListFile8 = ($1newfile & ("8.txt"))

Global $iIndex = 0, $sListData9 = ($1newfile & ("9.txt"))
Global $sListFile9 = ($1newfile & ("9.txt"))

Global $iIndex = 0, $sListData10 = ($1newfile & ("10.txt"))
Global $sListFile10 = ($1newfile & ("10.txt"))

Global $iIndex = 0, $sListData11 = ($1newfile & ("11.txt"))
Global $sListFile11 = ($1newfile & ("11.txt"))

Global $iIndex = 0, $sListData12 = ($1newfile & ("12.txt"))
Global $sListFile12 = ($1newfile & ("12.txt"))

Global $iIndex = 0, $sListData13 = ($1newfile & ("13.txt"))
Global $sListFile13 = ($1newfile & ("13.txt"))







; Read saved file if it exists--------
If FileExists($sListFile1) Then
$sListData1 = FileRead($sListFile1)
Else
MsgBox($MB_SYSTEMMODAL, "Error", $sListFile1 & " does not exist") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndIf

; Load data read from the file
GUICtrlSetData($List1, $sListData1)
_GUICtrlListBox_SetCurSel($List1, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile2) Then
$sListData2 = FileRead($sListFile2)
EndIf




; Load data read from the file
GUICtrlSetData($List2, $sListData2)
_GUICtrlListBox_SetCurSel($List2, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile3) Then
$sListData3 = FileRead($sListFile3)
EndIf




; Load data read from the file
GUICtrlSetData($List3, $sListData3)
_GUICtrlListBox_SetCurSel($List3, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile4) Then
$sListData4 = FileRead($sListFile4)
EndIf




; Load data read from the file
GUICtrlSetData($List4, $sListData4)
_GUICtrlListBox_SetCurSel($List4, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile5) Then
$sListData5 = FileRead($sListFile5)
EndIf



; Load data read from the file
GUICtrlSetData($List5, $sListData5)
_GUICtrlListBox_SetCurSel($List5, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile6) Then
$sListData6 = FileRead($sListFile6)
EndIf

; Load data read from the file
GUICtrlSetData($List6, $sListData6)
_GUICtrlListBox_SetCurSel($List6, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile7) Then
$sListData7 = FileRead($sListFile7)
EndIf

; Load data read from the file
GUICtrlSetData($List7, $sListData7)
_GUICtrlListBox_SetCurSel($List7, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile8) Then
$sListData8 = FileRead($sListFile8)
EndIf

; Load data read from the file
GUICtrlSetData($List8, $sListData8)
_GUICtrlListBox_SetCurSel($List8, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile9) Then
$sListData9 = FileRead($sListFile9)
EndIf

; Load data read from the file
GUICtrlSetData($List9, $sListData9)
_GUICtrlListBox_SetCurSel($List9, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile10) Then
$sListData10 = FileRead($sListFile10)
EndIf

EndFunc








While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Button1

            $iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)






            If $iIndex = _GUICtrlListBox_GetCount($List4) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List4, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List2) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List2, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List3) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List3, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List9) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List9, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List5) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List5, $iIndex)






    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Do you use MsgBox's to display values for variables at various points during testing your script?

If not, you should, as they are a great help when troubleshooting.

I'm still not sure what you are trying to achieve with $Button1 ?

Your $Index variable goes up by 1 each time you click it, until it matches the count of one of your lists, when it sets the selection for that list to the first line/entry, otherwise it appears to select the same line number on each list. Is that your intent?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

 

Your $Index variable goes up by 1 each time you click it, until it matches the count of one of your lists, when it sets the selection for that list to the first line/entry, otherwise it appears to select the same line number on each list. Is that your intent?

yes its a part of the script the full scipt has more tah 50,000 lines so that would be unimportand ,

this function should select the name bellow the first one in list1,

but its just one of the few functions if i use one of the other 29 functions it would not work either

Edited by Arclite86

Share this post


Link to post
Share on other sites

Well, all I can suggest, is that you clearly define what is supposed to be going on overall, and at each relevant stage, and of course, the MsgBox troubleshooting suggestion would be best used at those points (and no doubt others), to work out what is exactly currently going on.

You need to step through your logic, and while you do have a few comment lines, you should have a lot more, as they would especially help us to determine, via your expectations and the actual reality, what is askew.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

It seems that  second while:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $Button1

            $iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)






            If $iIndex = _GUICtrlListBox_GetCount($List4) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List4, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List2) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List2, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List3) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List3, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List9) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List9, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List5) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List5, $iIndex)






    EndSwitch
WEnd

just doesnt respondse because of the first while 1 thats in the GUI Section

For $i = 1 To 13
FileDelete(@ScriptDir & "\list" & $i & ".txt")
FileWrite(@ScriptDir & "\list" & $i & ".txt", "text " & $i)
Next

Global $iIndex = 0
#Region ### START Koda GUI section ### Form=
$Form1_1_1_1 = GUICreate("program", 814, 713, 697, 101)
$Button1 = GUICtrlCreateButton("Next", 208, 0, 41, 25)
$List1 = GUICtrlCreateList("", 0, 64, 145, 358)
GUICtrlSetData(-1, "")
$List2 = GUICtrlCreateList("", 144, 64, 65, 358)
GUICtrlSetData(-1, "")
$List3 = GUICtrlCreateList("", 208, 64, 65, 358)
GUICtrlSetData(-1, "")
$List4 = GUICtrlCreateList("", 344, 64, 153, 358)
GUICtrlSetData(-1, "")
$List5 = GUICtrlCreateList("", 496, 64, 65, 358)
GUICtrlSetData(-1, "")
$List6 = GUICtrlCreateList("", 560, 64, 121, 230)
GUICtrlSetData(-1, "")
$List7 = GUICtrlCreateList("", 680, 64, 65, 230)
GUICtrlSetData(-1, "")
$List8 = GUICtrlCreateList("", 744, 64, 65, 230)
GUICtrlSetData(-1, "")
$List9 = GUICtrlCreateList("", 272, 64, 65, 358)
GUICtrlSetData(-1, "")

GUISetState(@SW_SHOW)

Local $helpmenu, $infoitem, $exititem, $recentfilesmenu
Local $viewmenu, $viewstatusitem
Local $statuslabel, $msg, $file



$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$newitem = GUICtrlCreateMenuItem("new", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
GUICtrlCreateMenuItem("Save", $filemenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("Info", $helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1)

GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)
$message4 = GUICtrlCreateMenuItem("message", $filemenu)




GUICtrlSetState(-1, $GUI_FOCUS)




GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1

$msg = GUIGetMsg()

If $msg = $fileitem Then
ConsoleWrite("Hit" & @CRLF)

$file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
If @error <> 1 Then
GUICtrlCreateMenuItem($file, $recentfilesmenu)
_FillLists($file)
EndIf
EndIf
if $msg = $newitem Then
$newitem = FileSaveDialog("Choose file...", @TempDir, "All (*.*)")

EndIf
If $msg = $viewstatusitem Then
If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)
GUICtrlSetState($statuslabel, $GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem, $GUI_CHECKED)
GUICtrlSetState($statuslabel, $GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then ExitLoop


If $msg = $infoitem Then MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")



WEnd
GUIDelete()

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

Is there a way I get cat the menu function in the second  while (after the GUI section) I that that will solve the problem

Share this post


Link to post
Share on other sites

Why not just put the second while loop inside the first (not two loops, but one complete While loop)?

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

If you mean this, I have tried it but it tells me to use Wend , even though there already is

$_FF_COM_TRACE = True
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
;#include <FF.au3>
#include <staticConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <Excel.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
Local $oIE
;, BitOR($WS_BORDER, $WS_VSCROLL)

;_FFStart( "https://www.google.nl" )
;WinSetState ( "Google - Mozilla Firefox", "", @SW_MINIMIZE )








;~ _GUIExtender_Init($Form1_1_1_1)

For $i = 1 To 13
FileDelete(@ScriptDir & "\list" & $i & ".txt")
FileWrite(@ScriptDir & "\list" & $i & ".txt", "text " & $i)
Next

Global $iIndex = 0
#Region ### START Koda GUI section ### Form=
$Form1_1_1_1 = GUICreate("program", 814, 713, 697, 101)
$Button1 = GUICtrlCreateButton("Next", 208, 0, 41, 25)
$List1 = GUICtrlCreateList("", 0, 64, 145, 358)
GUICtrlSetData(-1, "")
$List2 = GUICtrlCreateList("", 144, 64, 65, 358)
GUICtrlSetData(-1, "")
$List3 = GUICtrlCreateList("", 208, 64, 65, 358)
GUICtrlSetData(-1, "")
$List4 = GUICtrlCreateList("", 344, 64, 153, 358)
GUICtrlSetData(-1, "")
$List5 = GUICtrlCreateList("", 496, 64, 65, 358)
GUICtrlSetData(-1, "")
$List6 = GUICtrlCreateList("", 560, 64, 121, 230)
GUICtrlSetData(-1, "")
$List7 = GUICtrlCreateList("", 680, 64, 65, 230)
GUICtrlSetData(-1, "")
$List8 = GUICtrlCreateList("", 744, 64, 65, 230)
GUICtrlSetData(-1, "")
$List9 = GUICtrlCreateList("", 272, 64, 65, 358)
GUICtrlSetData(-1, "")

GUISetState(@SW_SHOW)

Local $helpmenu, $infoitem, $exititem, $recentfilesmenu
Local $viewmenu, $viewstatusitem
Local $statuslabel, $msg, $file



$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$newitem = GUICtrlCreateMenuItem("new", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
GUICtrlCreateMenuItem("Save", $filemenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("Info", $helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1)

GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)
$message4 = GUICtrlCreateMenuItem("message", $filemenu)




GUICtrlSetState(-1, $GUI_FOCUS)




GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1


$msg = GUIGetMsg()

If $msg = $fileitem Then
ConsoleWrite("Hit" & @CRLF)

$file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
If @error <> 1 Then
GUICtrlCreateMenuItem($file, $recentfilesmenu)
_FillLists($file)
EndIf
EndIf
if $msg = $newitem Then
$newitem = FileSaveDialog("Choose file...", @TempDir, "All (*.*)")

EndIf
If $msg = $viewstatusitem Then
If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)
GUICtrlSetState($statuslabel, $GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem, $GUI_CHECKED)
GUICtrlSetState($statuslabel, $GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then ExitLoop


If $msg = $infoitem Then MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")


Case $Button1

            $iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)






            If $iIndex = _GUICtrlListBox_GetCount($List4) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List4, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List2) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List2, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List3) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List3, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List9) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List9, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List5) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List5, $iIndex)



Wend
GUIDelete()

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

Func _FillLists($file)


Local $newfile = StringReplace($file, "Openfile.txt", "")

$1newfile = ($newfile & ("lists\list"))


Global $iIndex = 0, $sListData1 = ($1newfile & ("1.txt"))
Global $sListFile1 = ($1newfile & ("1.txt"))

Global $iIndex = 0, $sListData2 = ($1newfile & ("2.txt"))
Global $sListFile2 = ($1newfile & ("2.txt"))

Global $iIndex = 0, $sListData3 = ($1newfile & ("3.txt"))
Global $sListFile3 = ($1newfile & ("3.txt"))

Global $iIndex = 0, $sListData4 = ($1newfile & ("4.txt"))
Global $sListFile4 = ($1newfile & ("4.txt"))

Global $iIndex = 0, $sListData5 = ($1newfile & ("5.txt"))
Global $sListFile5 = ($1newfile & ("5.txt"))

Global $iIndex = 0, $sListData6 = ($1newfile & ("6.txt"))
Global $sListFile6 = ($1newfile & ("6.txt"))

Global $iIndex = 0, $sListData7 = ($1newfile & ("7.txt"))
Global $sListFile7 = ($1newfile & ("7.txt"))

Global $iIndex = 0, $sListData8 = ($1newfile & ("8.txt"))
Global $sListFile8 = ($1newfile & ("8.txt"))

Global $iIndex = 0, $sListData9 = ($1newfile & ("9.txt"))
Global $sListFile9 = ($1newfile & ("9.txt"))

Global $iIndex = 0, $sListData10 = ($1newfile & ("10.txt"))
Global $sListFile10 = ($1newfile & ("10.txt"))

Global $iIndex = 0, $sListData11 = ($1newfile & ("11.txt"))
Global $sListFile11 = ($1newfile & ("11.txt"))

Global $iIndex = 0, $sListData12 = ($1newfile & ("12.txt"))
Global $sListFile12 = ($1newfile & ("12.txt"))

Global $iIndex = 0, $sListData13 = ($1newfile & ("13.txt"))
Global $sListFile13 = ($1newfile & ("13.txt"))







; Read saved file if it exists--------
If FileExists($sListFile1) Then
$sListData1 = FileRead($sListFile1)
Else
MsgBox($MB_SYSTEMMODAL, "Error", $sListFile1 & " does not exist") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndIf

; Load data read from the file
GUICtrlSetData($List1, $sListData1)
_GUICtrlListBox_SetCurSel($List1, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile2) Then
$sListData2 = FileRead($sListFile2)
EndIf




; Load data read from the file
GUICtrlSetData($List2, $sListData2)
_GUICtrlListBox_SetCurSel($List2, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile3) Then
$sListData3 = FileRead($sListFile3)
EndIf




; Load data read from the file
GUICtrlSetData($List3, $sListData3)
_GUICtrlListBox_SetCurSel($List3, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile4) Then
$sListData4 = FileRead($sListFile4)
EndIf




; Load data read from the file
GUICtrlSetData($List4, $sListData4)
_GUICtrlListBox_SetCurSel($List4, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile5) Then
$sListData5 = FileRead($sListFile5)
EndIf



; Load data read from the file
GUICtrlSetData($List5, $sListData5)
_GUICtrlListBox_SetCurSel($List5, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile6) Then
$sListData6 = FileRead($sListFile6)
EndIf

; Load data read from the file
GUICtrlSetData($List6, $sListData6)
_GUICtrlListBox_SetCurSel($List6, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile7) Then
$sListData7 = FileRead($sListFile7)
EndIf

; Load data read from the file
GUICtrlSetData($List7, $sListData7)
_GUICtrlListBox_SetCurSel($List7, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile8) Then
$sListData8 = FileRead($sListFile8)
EndIf

; Load data read from the file
GUICtrlSetData($List8, $sListData8)
_GUICtrlListBox_SetCurSel($List8, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile9) Then
$sListData9 = FileRead($sListFile9)
EndIf

; Load data read from the file
GUICtrlSetData($List9, $sListData9)
_GUICtrlListBox_SetCurSel($List9, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile10) Then
$sListData10 = FileRead($sListFile10)
EndIf

EndFunc

Share this post


Link to post
Share on other sites

@Arclite86 - Like I said, you need to put comments in your code to help us, but also for yourself, to understand your expectations etc. You may be surprised, at how much it helps you to go through your code and interpret it.

Comments and testing variables is the best way to troubleshoot ... and learn, plus improve your coding skill.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I dont get it take a look at this, this is what im getting:

2133uvn.jpg

at the beginning it tels to close the while and a the and it says missing Wend, even though there is.

Guys if have been trying and looking at this for hours and I cant  see the issue please help me,

Share this post


Link to post
Share on other sites

If I try this the $button1 will work but it just starts at the beginning but doesn't end..

$_FF_COM_TRACE = True
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
;#include <FF.au3>
#include <staticConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <Excel.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
Local $oIE
;, BitOR($WS_BORDER, $WS_VSCROLL)

;_FFStart( "https://www.google.nl" )
;WinSetState ( "Google - Mozilla Firefox", "", @SW_MINIMIZE )








;~ _GUIExtender_Init($Form1_1_1_1)

For $i = 1 To 13
FileDelete(@ScriptDir & "\list" & $i & ".txt")
FileWrite(@ScriptDir & "\list" & $i & ".txt", "text " & $i)
Next

Global $iIndex = 0
#Region ### START Koda GUI section ### Form=
$Form1_1_1_1 = GUICreate("program", 814, 713, 697, 101)
$Button1 = GUICtrlCreateButton("Next", 208, 0, 41, 25)
$List1 = GUICtrlCreateList("", 0, 64, 145, 358)
GUICtrlSetData(-1, "")
$List2 = GUICtrlCreateList("", 144, 64, 65, 358)
GUICtrlSetData(-1, "")
$List3 = GUICtrlCreateList("", 208, 64, 65, 358)
GUICtrlSetData(-1, "")
$List4 = GUICtrlCreateList("", 344, 64, 153, 358)
GUICtrlSetData(-1, "")
$List5 = GUICtrlCreateList("", 496, 64, 65, 358)
GUICtrlSetData(-1, "")
$List6 = GUICtrlCreateList("", 560, 64, 121, 230)
GUICtrlSetData(-1, "")
$List7 = GUICtrlCreateList("", 680, 64, 65, 230)
GUICtrlSetData(-1, "")
$List8 = GUICtrlCreateList("", 744, 64, 65, 230)
GUICtrlSetData(-1, "")
$List9 = GUICtrlCreateList("", 272, 64, 65, 358)
GUICtrlSetData(-1, "")

GUISetState(@SW_SHOW)

Local $helpmenu, $infoitem, $exititem, $recentfilesmenu
Local $viewmenu, $viewstatusitem
Local $statuslabel, $msg, $file



$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$newitem = GUICtrlCreateMenuItem("new", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
GUICtrlCreateMenuItem("Save", $filemenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("Info", $helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1)

GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)
$message4 = GUICtrlCreateMenuItem("message", $filemenu)




GUICtrlSetState(-1, $GUI_FOCUS)




GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1


$msg = GUIGetMsg()

If $msg = $fileitem Then
ConsoleWrite("Hit" & @CRLF)

$file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
If @error <> 1 Then
GUICtrlCreateMenuItem($file, $recentfilesmenu)
_FillLists($file)
EndIf
EndIf
if $msg = $newitem Then
$newitem = FileSaveDialog("Choose file...", @TempDir, "All (*.*)")

EndIf
If $msg = $viewstatusitem Then
If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)
GUICtrlSetState($statuslabel, $GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem, $GUI_CHECKED)
GUICtrlSetState($statuslabel, $GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then ExitLoop


If $msg = $infoitem Then MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")




            $iIndex += 1
            If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List1, $iIndex)






            If $iIndex = _GUICtrlListBox_GetCount($List4) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List4, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List2) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List2, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List3) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List3, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List9) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List9, $iIndex)

            If $iIndex = _GUICtrlListBox_GetCount($List5) Then $iIndex = 0
            _GUICtrlListBox_SetCurSel($List5, $iIndex)


WEnd

GUIDelete()

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

Func _FillLists($file)


Local $newfile = StringReplace($file, "Openfile.txt", "")

$1newfile = ($newfile & ("lists\list"))


Global $iIndex = 0, $sListData1 = ($1newfile & ("1.txt"))
Global $sListFile1 = ($1newfile & ("1.txt"))

Global $iIndex = 0, $sListData2 = ($1newfile & ("2.txt"))
Global $sListFile2 = ($1newfile & ("2.txt"))

Global $iIndex = 0, $sListData3 = ($1newfile & ("3.txt"))
Global $sListFile3 = ($1newfile & ("3.txt"))

Global $iIndex = 0, $sListData4 = ($1newfile & ("4.txt"))
Global $sListFile4 = ($1newfile & ("4.txt"))

Global $iIndex = 0, $sListData5 = ($1newfile & ("5.txt"))
Global $sListFile5 = ($1newfile & ("5.txt"))

Global $iIndex = 0, $sListData6 = ($1newfile & ("6.txt"))
Global $sListFile6 = ($1newfile & ("6.txt"))

Global $iIndex = 0, $sListData7 = ($1newfile & ("7.txt"))
Global $sListFile7 = ($1newfile & ("7.txt"))

Global $iIndex = 0, $sListData8 = ($1newfile & ("8.txt"))
Global $sListFile8 = ($1newfile & ("8.txt"))

Global $iIndex = 0, $sListData9 = ($1newfile & ("9.txt"))
Global $sListFile9 = ($1newfile & ("9.txt"))

Global $iIndex = 0, $sListData10 = ($1newfile & ("10.txt"))
Global $sListFile10 = ($1newfile & ("10.txt"))

Global $iIndex = 0, $sListData11 = ($1newfile & ("11.txt"))
Global $sListFile11 = ($1newfile & ("11.txt"))

Global $iIndex = 0, $sListData12 = ($1newfile & ("12.txt"))
Global $sListFile12 = ($1newfile & ("12.txt"))

Global $iIndex = 0, $sListData13 = ($1newfile & ("13.txt"))
Global $sListFile13 = ($1newfile & ("13.txt"))







; Read saved file if it exists--------
If FileExists($sListFile1) Then
$sListData1 = FileRead($sListFile1)
Else
MsgBox($MB_SYSTEMMODAL, "Error", $sListFile1 & " does not exist") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndIf

; Load data read from the file
GUICtrlSetData($List1, $sListData1)
_GUICtrlListBox_SetCurSel($List1, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile2) Then
$sListData2 = FileRead($sListFile2)
EndIf




; Load data read from the file
GUICtrlSetData($List2, $sListData2)
_GUICtrlListBox_SetCurSel($List2, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile3) Then
$sListData3 = FileRead($sListFile3)
EndIf




; Load data read from the file
GUICtrlSetData($List3, $sListData3)
_GUICtrlListBox_SetCurSel($List3, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile4) Then
$sListData4 = FileRead($sListFile4)
EndIf




; Load data read from the file
GUICtrlSetData($List4, $sListData4)
_GUICtrlListBox_SetCurSel($List4, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile5) Then
$sListData5 = FileRead($sListFile5)
EndIf



; Load data read from the file
GUICtrlSetData($List5, $sListData5)
_GUICtrlListBox_SetCurSel($List5, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile6) Then
$sListData6 = FileRead($sListFile6)
EndIf

; Load data read from the file
GUICtrlSetData($List6, $sListData6)
_GUICtrlListBox_SetCurSel($List6, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile7) Then
$sListData7 = FileRead($sListFile7)
EndIf

; Load data read from the file
GUICtrlSetData($List7, $sListData7)
_GUICtrlListBox_SetCurSel($List7, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile8) Then
$sListData8 = FileRead($sListFile8)
EndIf

; Load data read from the file
GUICtrlSetData($List8, $sListData8)
_GUICtrlListBox_SetCurSel($List8, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile9) Then
$sListData9 = FileRead($sListFile9)
EndIf

; Load data read from the file
GUICtrlSetData($List9, $sListData9)
_GUICtrlListBox_SetCurSel($List9, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile10) Then
$sListData10 = FileRead($sListFile10)
EndIf

EndFunc


While 2
    $nMsg = GUIGetMsg()
    Switch $nMsg
Case $Button1
$iIndex += 1
    _GUICtrlListBox_SetCurSel($List6, $iIndex)
    _GUICtrlListBox_SetCurSel($List7, $iIndex)
    _GUICtrlListBox_SetCurSel($List8, $iIndex)

        EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Arclite86,

Inside your GUIGetMsg loop you use:

$msg = GUIGetMsg()
    If $msg =
for all events bar $Button1 where for some reason you inexplicably use:

Case $Button1
So Tidy thinks you are in a Switch structure and gives you the completely accurate message:

### Tidy Error -> "wend" is closing previous "case" on line 133
Change the $Button1 event code to match that you use for the other events and the code should run. :)

Top Tip: Use the checking tools available (Tidy, Au3Check, etc) to check your code if it does nto run as expected - they are not infallible but as in this case they can help a lot. ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

my last question how do I put a function in one of these

$msg = GUIGetMsg()
    If $msg =

I have tried this

If $msg = $Button1 then
pluseen()

endif

Func _pluseen($button1)

    $iIndex += 1
    _GUICtrlListBox_SetCurSel($List6, $iIndex)
    _GUICtrlListBox_SetCurSel($List7, $iIndex)
    _GUICtrlListBox_SetCurSel($List8, $iIndex)


    If GUICtrlRead($lnewlistcount) < 14 Then
        GUICtrlSetData($lnewlistcount, GUICtrlRead($lnewlistcount) + 1)
    ElseIf GUICtrlRead($lnewlistcount) = 14 Then
        GUICtrlSetData($lnewlistcount, 0)
    EndIf

EndFunc

I have ried this but it doesnt work.

Share this post


Link to post
Share on other sites

Declare the function outside the loop and call it inside the loop. ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

I did this, it worked but sometimes it doesnt react than I have to click 3 or 4 times until the function works, is there a way It can be improved?

$_FF_COM_TRACE = True
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
;#include <FF.au3>
#include <staticConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <Excel.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
Local $oIE
;, BitOR($WS_BORDER, $WS_VSCROLL)

;_FFStart( "https://www.google.nl" )
;WinSetState ( "Google - Mozilla Firefox", "", @SW_MINIMIZE )








;~ _GUIExtender_Init($Form1_1_1_1)

For $i = 1 To 13
FileDelete(@ScriptDir & "\list" & $i & ".txt")
FileWrite(@ScriptDir & "\list" & $i & ".txt", "text " & $i)
Next

Global $iIndex = 0
#Region ### START Koda GUI section ### Form=
$Form1_1_1_1 = GUICreate("program", 814, 713, 697, 101)
$Button1 = GUICtrlCreateButton("Next", 208, 0, 41, 25)
$List1 = GUICtrlCreateList("", 0, 64, 145, 358)
GUICtrlSetData(-1, "")
$List2 = GUICtrlCreateList("", 144, 64, 65, 358)
GUICtrlSetData(-1, "")
$List3 = GUICtrlCreateList("", 208, 64, 65, 358)
GUICtrlSetData(-1, "")
$List4 = GUICtrlCreateList("", 344, 64, 153, 358)
GUICtrlSetData(-1, "")
$List5 = GUICtrlCreateList("", 496, 64, 65, 358)
GUICtrlSetData(-1, "")
$List6 = GUICtrlCreateList("", 560, 64, 121, 230)
GUICtrlSetData(-1, "")
$List7 = GUICtrlCreateList("", 680, 64, 65, 230)
GUICtrlSetData(-1, "")
$List8 = GUICtrlCreateList("", 744, 64, 65, 230)
GUICtrlSetData(-1, "")
$List9 = GUICtrlCreateList("", 272, 64, 65, 358)
GUICtrlSetData(-1, "")

GUISetState(@SW_SHOW)

Local $helpmenu, $infoitem, $exititem, $recentfilesmenu
Local $viewmenu, $viewstatusitem
Local $statuslabel, $msg, $file



$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$newitem = GUICtrlCreateMenuItem("new", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
GUICtrlCreateMenuItem("Save", $filemenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("Info", $helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1)

GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)
$message4 = GUICtrlCreateMenuItem("message", $filemenu)




GUICtrlSetState(-1, $GUI_FOCUS)




GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1


$msg = GUIGetMsg()

If $msg = $fileitem Then
ConsoleWrite("Hit" & @CRLF)

$file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
If @error <> 1 Then
GUICtrlCreateMenuItem($file, $recentfilesmenu)
_FillLists($file)
EndIf
EndIf
if $msg = $newitem Then
$newitem = FileSaveDialog("Choose file...", @TempDir, "All (*.*)")

EndIf
If $msg = $viewstatusitem Then
If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)
GUICtrlSetState($statuslabel, $GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem, $GUI_CHECKED)
GUICtrlSetState($statuslabel, $GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then ExitLoop


If $msg = $infoitem Then MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")


$msg = GUIGetMsg()
    If $msg = $Button1 then


_pluseen($Button1)

EndIf
WEnd
GUIDelete()

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

Func _FillLists($file)


Local $newfile = StringReplace($file, "Openfile.txt", "")

$1newfile = ($newfile & ("lists\list"))


Global $iIndex = 0, $sListData1 = ($1newfile & ("1.txt"))
Global $sListFile1 = ($1newfile & ("1.txt"))

Global $iIndex = 0, $sListData2 = ($1newfile & ("2.txt"))
Global $sListFile2 = ($1newfile & ("2.txt"))

Global $iIndex = 0, $sListData3 = ($1newfile & ("3.txt"))
Global $sListFile3 = ($1newfile & ("3.txt"))

Global $iIndex = 0, $sListData4 = ($1newfile & ("4.txt"))
Global $sListFile4 = ($1newfile & ("4.txt"))

Global $iIndex = 0, $sListData5 = ($1newfile & ("5.txt"))
Global $sListFile5 = ($1newfile & ("5.txt"))

Global $iIndex = 0, $sListData6 = ($1newfile & ("6.txt"))
Global $sListFile6 = ($1newfile & ("6.txt"))

Global $iIndex = 0, $sListData7 = ($1newfile & ("7.txt"))
Global $sListFile7 = ($1newfile & ("7.txt"))

Global $iIndex = 0, $sListData8 = ($1newfile & ("8.txt"))
Global $sListFile8 = ($1newfile & ("8.txt"))

Global $iIndex = 0, $sListData9 = ($1newfile & ("9.txt"))
Global $sListFile9 = ($1newfile & ("9.txt"))

Global $iIndex = 0, $sListData10 = ($1newfile & ("10.txt"))
Global $sListFile10 = ($1newfile & ("10.txt"))

Global $iIndex = 0, $sListData11 = ($1newfile & ("11.txt"))
Global $sListFile11 = ($1newfile & ("11.txt"))

Global $iIndex = 0, $sListData12 = ($1newfile & ("12.txt"))
Global $sListFile12 = ($1newfile & ("12.txt"))

Global $iIndex = 0, $sListData13 = ($1newfile & ("13.txt"))
Global $sListFile13 = ($1newfile & ("13.txt"))







; Read saved file if it exists--------
If FileExists($sListFile1) Then
$sListData1 = FileRead($sListFile1)
Else
MsgBox($MB_SYSTEMMODAL, "Error", $sListFile1 & " does not exist") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndIf

; Load data read from the file
GUICtrlSetData($List1, $sListData1)
_GUICtrlListBox_SetCurSel($List1, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile2) Then
$sListData2 = FileRead($sListFile2)
EndIf




; Load data read from the file
GUICtrlSetData($List2, $sListData2)
_GUICtrlListBox_SetCurSel($List2, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile3) Then
$sListData3 = FileRead($sListFile3)
EndIf




; Load data read from the file
GUICtrlSetData($List3, $sListData3)
_GUICtrlListBox_SetCurSel($List3, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile4) Then
$sListData4 = FileRead($sListFile4)
EndIf




; Load data read from the file
GUICtrlSetData($List4, $sListData4)
_GUICtrlListBox_SetCurSel($List4, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile5) Then
$sListData5 = FileRead($sListFile5)
EndIf



; Load data read from the file
GUICtrlSetData($List5, $sListData5)
_GUICtrlListBox_SetCurSel($List5, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile6) Then
$sListData6 = FileRead($sListFile6)
EndIf

; Load data read from the file
GUICtrlSetData($List6, $sListData6)
_GUICtrlListBox_SetCurSel($List6, $iIndex)

; Read saved file if it exists--------
If FileExists($sListFile7) Then
$sListData7 = FileRead($sListFile7)
EndIf

; Load data read from the file
GUICtrlSetData($List7, $sListData7)
_GUICtrlListBox_SetCurSel($List7, $iIndex)




; Read saved file if it exists--------
If FileExists($sListFile8) Then
$sListData8 = FileRead($sListFile8)
EndIf

; Load data read from the file
GUICtrlSetData($List8, $sListData8)
_GUICtrlListBox_SetCurSel($List8, $iIndex)



; Read saved file if it exists--------
If FileExists($sListFile9) Then
$sListData9 = FileRead($sListFile9)
EndIf

; Load data read from the file
GUICtrlSetData($List9, $sListData9)
_GUICtrlListBox_SetCurSel($List9, $iIndex)


; Read saved file if it exists--------
If FileExists($sListFile10) Then
$sListData10 = FileRead($sListFile10)
EndIf

EndFunc

Func _pluseen($Button1)

    $iIndex += 1
    _GUICtrlListBox_SetCurSel($List1, $iIndex)
    _GUICtrlListBox_SetCurSel($List4, $iIndex)





EndFunc

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  

×
×
  • Create New...