Try this highly modified version. I generalized most of the functions. Tell me what you think...
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -d
#AutoIt3Wrapper_Run_Tidy=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <staticconstants.au3>
AutoItSetOption("trayicondebug", 1)
Global Const $plDataIni = @ScriptDir & "\pldata.ini"
If Not FileExists($plDataIni) Then firstrun
()
Global $proga[10], $progb[10], $progc[10]
Global $htab, $add1, $add2, $add3, $fileitem1, $fileitem2, $main, $remove1, $remove2, $remove3
Global $aup, $aup1, $adown, $adown1, $bup, $bup1, $bdown, $bdown1, $cup, $cup1, $cdown, $cdown1
Global $a = 1, $b = 1, $c = 1, $msg, $run, $w, $y, $taba, $tabb, $tabc
gui
()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $add1
CreatePath
('a')
Case $msg = $add2
CreatePath
('b')
Case $msg = $add3
CreatePath
('c')
Case $msg = $fileitem1
addtab
()
Case $msg = $fileitem2
DeleteTab
()
;~ Case $msg = $remove1
;~ RemoveTab()
;~ Case $msg = $remove2
;~ RemoveTab('b')
;~ Case $msg = $remove3
;~ RemoveTab('b')
Case $msg = $adown
_FileReadToArray(@ScriptDir & "\taba.cfg", $taba)
If IsArray($taba) Then
$a += 5
If $a > $taba[0] Then $a = $taba[0]
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $adown1
_FileReadToArray(@ScriptDir & "\taba.cfg", $taba)
If IsArray($taba) Then
$a += 1
If $a > $taba[0] Then $a = $taba[0]
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $aup
_FileReadToArray(@ScriptDir & "\taba.cfg", $taba)
If IsArray($taba) Then
$a -= 5
If $a < 1 Then $a = 1
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $aup1
_FileReadToArray(@ScriptDir & "\taba.cfg", $taba)
If IsArray($taba) Then
$a -= 1
If $a < 1 Then $a = 1
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $bdown
_FileReadToArray(@ScriptDir & "\tabb.cfg", $tabb)
If IsArray($tabb) Then
$b += 5
If $b > $tabb[0] Then $b = $tabb[0]
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $bdown1
_FileReadToArray(@ScriptDir & "\tabb.cfg", $tabb)
If IsArray($tabb) Then
$b += 1
If $b > $tabb[0] Then $b = $tabb[0]
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $bup
_FileReadToArray(@ScriptDir & "\tabb.cfg", $tabb)
If IsArray($tabb) Then
$b -= 5
If $b < 1 Then $b = 1
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $bup1
_FileReadToArray(@ScriptDir & "\tabb.cfg", $tabb)
If IsArray($tabb) Then
$b -= 1
If $b < 1 Then $b = 1
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $cdown
_FileReadToArray(@ScriptDir & "\tabc.cfg", $tabc)
If IsArray($tabc) Then
$c += 5
If $c > $tabc[0] Then $c = $tabc[0]
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $cdown1
_FileReadToArray(@ScriptDir & "\tabc.cfg", $tabc)
If IsArray($tabc) Then
$c += 1
If $c > $tabc[0] Then $c = $tabc[0]
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $cup
_FileReadToArray(@ScriptDir & "\tabc.cfg", $tabc)
If IsArray($tabc) Then
$c -= 5
If $c < 1 Then $c = 1
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $cup1
_FileReadToArray(@ScriptDir & "\tabc.cfg", $tabc)
If IsArray($tabc) Then
$c -= 1
If $c < 1 Then $c = 1
pos
()
GUIDelete($main)
gui
()
EndIf
Case $msg = $GUI_EVENT_CLOSE
pos
()
GUIDelete()
Exit (1)
Case $msg > 0
$run = GUICtrlRead($msg)
Run($run)
EndSelect
WEnd
; =====================================================================================================
Func addtab
()
ConsoleWrite('@@ (216) :(' & @MIN & ':' & @SEC & ') addtab()' & @CR) ;### Function Trace
; nothing
EndFunc ;==>addtab
; =====================================================================================================
Func CreatePath
(Const $abc)
ConsoleWrite('@@ (223) :(' & @MIN & ':' & @SEC & ') CreatePath()' & @CR) ;### Function Trace
Local Const $adpro = GUICreate("Add Program", 200, 30, -1, -1, -1, $WS_EX_ACCEPTFILES)
Local Const $ftpr = GUICtrlCreateInput('', 1, 4, 160, 20)
GUICtrlSetState($ftpr, $GUI_DROPACCEPTED)
Local Const $prin = GUICtrlCreateButton("OK", 165, 1)
GUISetState(@SW_SHOW)
Local $msg2
While 1
$msg2 = GUIGetMsg()
Select
Case $msg2 = $prin
Local Const $read = GUICtrlRead($ftpr)
FileWriteLine(@ScriptDir & "\tab" & $abc & ".cfg", $read)
ExitLoop
Case $msg2 = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
GUIDelete($adpro)
pos
()
Tab($abc)
EndFunc ;==>CreatePath
; =====================================================================================================
Func CreateTab
(ByRef $tabArray, Const $abc)
ConsoleWrite('@@ (263) :(' & @MIN & ':' & @SEC & ') CreateTab()' & @CR) ;### Function Trace
Local $y = 0
For $i = 0 To UBound($tabArray) - 1
$tabArray[$i] = GUICtrlCreateLabel('', 65, $y + 15, 185, 24)
$y += 40
Next
Tab($abc)
EndFunc ;==>CreateTab
; =====================================================================================================
Func DeleteTab
()
ConsoleWrite('@@ (278) :(' & @MIN & ':' & @SEC & ') deltab()' & @CR) ;### Function Trace
Local $remtab[3]
For $i = 0 To UBound($remtab) - 1
$remtab[$i] = IniRead($plDataIni, "Tab", $i + 1, '')
Next
Local Const $remove = GUICreate("Remove", 400, 500)
Local Const $del = GUICtrlCreateButton("Delete", 180, 460, 50, 30)
Local Const $list = GUICtrlCreateListView("Select tab then click delete", 1, 1, 398, 450)
For $i = 0 To UBound($remtab) - 1
If $remtab[$i] <> '' Then
GUICtrlCreateListViewItem($remtab[$i] & '|', $list)
EndIf
Next
GUISetState(@SW_SHOW)
Local $msg2;, $select, $select1, $select2, $new, $new2, $file, $read
While 1
$msg2 = GUIGetMsg()
If $msg2 = $del Then
;~ $select = GUICtrlRead($list)
;~ $select1 = GUICtrlRead($select)
;~ $select2 = StringTrimRight($select1, 1)
;~ $read = FileRead($cfgFile)
;~ $new = StringReplace($read, $select2, '')
;~ $new2 = StringReplace($new, @LF & @LF, @LF)
;~ $file = FileOpen($cfgFile, 2)
;~ FileWrite($file, $new2)
;~ FileClose($file)
ExitLoop
ElseIf $msg2 = $GUI_EVENT_CLOSE Then
GUIDelete($remove)
ExitLoop
EndIf
WEnd
pos
()
GUIDelete($remove)
GUIDelete($main)
gui
()
EndFunc ;==>DeleteTab
; =====================================================================================================
Func firstrun
()
ConsoleWrite('@@ (285) :(' & @MIN & ':' & @SEC & ') firstrun()' & @CR) ;### Function Trace
Local Const $1 = InputBox("Enter Tab 1 Name", "Enter a Name for Tab 1", "Tab1")
IniWrite($plDataIni, "Tab", 1, $1)
Local Const $2 = InputBox("Enter Tab 2 Name", "Enter a Name for Tab 2", "Tab2")
IniWrite($plDataIni, "Tab", 2, $2)
Local Const $3 = InputBox("Enter Tab 3 Name", "Enter a Name for Tab 3", "Tab3")
IniWrite($plDataIni, "Tab", 3, $3)
EndFunc ;==>firstrun
; =====================================================================================================
Func gui
()
ConsoleWrite('@@ (300) :(' & @MIN & ':' & @SEC & ') gui()' & @CR) ;### Function Trace
Local Const $posx = IniRead($plDataIni, "pos", 1, -1)
Local Const $posy = IniRead($plDataIni, "pos", 2, -1)
Local Const $tab1 = IniRead($plDataIni, "Tab", 1, "Tab1")
Local Const $tab2 = IniRead($plDataIni, "Tab", 2, "Tab2")
Local Const $tab3 = IniRead($plDataIni, "Tab", 3, "Tab3")
Local Const $curtab = Int(IniRead($plDataIni, "curtab", 1, $tab1))
$main = GUICreate("Program Launcher", 350, 446, $posx, $posy)
Local Const $filemenu = GUICtrlCreateMenu("Options")
$fileitem1 = GUICtrlCreateMenuItem("Add Tab", $filemenu)
$fileitem2 = GUICtrlCreateMenuItem("Remove Tab", $filemenu)
$htab = GUICtrlCreateTab(2, 2, 346, 426)
GUICtrlCreateTabItem($tab1)
CreateTab
($proga, 'a')
$add1 = GUICtrlCreateButton("Add Program", 95, 400, 73, 25)
$remove1 = GUICtrlCreateButton("Remove Program", 180, 400, 90, 25)
GUICtrlCreateLabel('', 324, 64, 22, 295, $SS_BLACKFRAME)
$aup = GUICtrlCreateButton("/\" & @CR & "/\", 323, 26, 22, 25, BitOR($BS_MULTILINE, $BS_CENTER))
$aup1 = GUICtrlCreateButton("/\", 323, 50, 22, 22, BitOR($BS_MULTILINE, $BS_CENTER))
$adown = GUICtrlCreateButton("\/" & @CR & "\/", 323, 373, 22, 25, BitOR($BS_MULTILINE, $BS_VCENTER))
$adown1 = GUICtrlCreateButton("\/", 323, 352, 22, 22, $BS_VCENTER)
GUICtrlCreateTabItem($tab2)
CreateTab
($progb, 'b')
$add2 = GUICtrlCreateButton("Add Program", 95, 400, 73, 25)
$remove2 = GUICtrlCreateButton("Remove Program", 180, 400, 90, 25)
GUICtrlCreateLabel('', 324, 64, 22, 295, $SS_BLACKFRAME)
$bup = GUICtrlCreateButton("/\" & @CR & "/\", 323, 26, 22, 25, BitOR($BS_MULTILINE, $BS_CENTER))
$bup1 = GUICtrlCreateButton("/\", 323, 50, 22, 22, BitOR($BS_MULTILINE, $BS_CENTER))
$bdown = GUICtrlCreateButton("\/" & @CR & "\/", 323, 373, 22, 25, BitOR($BS_MULTILINE, $BS_VCENTER))
$bdown1 = GUICtrlCreateButton("\/", 323, 352, 22, 22, $BS_VCENTER)
GUICtrlCreateTabItem($tab3)
CreateTab
($progc, 'c')
$add3 = GUICtrlCreateButton("Add Program", 95, 400, 73, 25)
$remove3 = GUICtrlCreateButton("Remove Program", 180, 400, 90, 25)
GUICtrlCreateLabel('', 324, 64, 22, 295, $SS_BLACKFRAME)
$cup = GUICtrlCreateButton("/\" & @CR & "/\", 323, 26, 22, 25, BitOR($BS_MULTILINE, $BS_CENTER))
$cup1 = GUICtrlCreateButton("/\", 323, 50, 22, 22, BitOR($BS_MULTILINE, $BS_CENTER))
$cdown = GUICtrlCreateButton("\/" & @CR & "\/", 323, 373, 22, 25, BitOR($BS_MULTILINE, $BS_VCENTER))
$cdown1 = GUICtrlCreateButton("\/", 323, 352, 22, 22, $BS_VCENTER)
GUICtrlCreateTabItem('')
GUICtrlSetState($curtab, $GUI_SHOW)
GUISetState(@SW_SHOW)
EndFunc ;==>gui
; =====================================================================================================
Func pos
()
ConsoleWrite('@@ (354) :(' & @MIN & ':' & @SEC & ') pos()' & @CR) ;### Function Trace
Local Const $pos = WinGetPos($main)
IniWrite($plDataIni, "pos", 1, $pos[0])
IniWrite($plDataIni, "pos", 2, $pos[1])
Local Const $curtab = Int(GUICtrlRead($htab, 1))
IniWrite($plDataIni, "curtab", 1, $curtab)
EndFunc ;==>pos
; =====================================================================================================
;~ Func RemoveTab(Const $abc)
;~ ConsoleWrite('@@ (367) :(' & @MIN & ':' & @SEC & ') RemoveTab()' & @CR) ;### Function Trace
;~ EndFunc ;==>RemoveTab
; =====================================================================================================
Func Tab(Const $abc)
ConsoleWrite('@@ (427) :(' & @MIN & ':' & @SEC & ') Tab()' & @CR) ;### Function Trace
Local $tab, $w = 1, $y = 25, $but[1], $execString
_FileReadToArray(@ScriptDir & "\tab" & $abc & ".cfg", $tab)
If IsArray($tab) Then
If (Int($tab[0]) - $a) > 9 Then
Local $name, $o
For $i = $a To $a + 8
If $tab[$i] <> '' Then
If $y > 385 Then
$y = 385
EndIf
GUICtrlCreateLabel('', 36, $y, 287, 40, $SS_BLACKFRAME)
$name = StringSplit($tab[$i], '\')
$o = $name[0]
Int($o)
If $w > 9 Then
$w = 9
EndIf
$execString = "GUICtrlSetData($prog" & $abc & "[$w], $name[$o])"
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & '$execString' & @LF & @LF & 'Return:' & @LF & $execString) ;### Debug MSGBOX
Execute($execString)
_ArrayAdd($but, $w)
$but[$w] = GUICtrlCreateButton('', 5, $y + 1, 40, 40, $BS_ICON)
GUICtrlSetData($but[$w], $tab[$i])
GUICtrlSetImage($but[$w], ' ' & $tab[$i] & ' ', 1)
$y += 40
$w += 1
EndIf
Next
ElseIf (Int($tab[0]) - $a) < 10 Then
For $i = $a To UBound($tab) - 1
If $tab[$i] <> '' Then
If $y > 385 Then
$y = 385
EndIf
GUICtrlCreateLabel($tab[$i], 36, $y, 287, 40, $SS_BLACKFRAME)
$name = StringSplit($tab[$i], '\')
$o = $name[0]
Int($o)
If $w > 9 Then
$w = 9
EndIf
$execString = "GUICtrlSetData($prog" & $abc & "[$w], $name[$o])"
Execute($execString)
_ArrayAdd($but, $w)
$but[$w] = GUICtrlCreateButton($tab[$i], 5, $y + 1, 40, 40, $BS_ICON)
GUICtrlSetData($but[$w], $tab[$i])
GUICtrlSetImage($but[$w], $tab[$i], 1)
$y += 40
$w += 1
EndIf
Next
EndIf
EndIf
EndFunc ;==>Tab
; =====================================================================================================