Launcher

08/26/2013 19:04 kimboy600#1
Hi everyone , first of all i'd like to give credits to K1ramoX for his Applebase's UDF
PHP Code:
#include "Apple Base.au3" ;include my base
#NoTrayIcon
DirCreate (@TempDir "\Pro_Loader")
$Toggled 1
HotKeySet 
("{INS}","_SH")
_Apple_Startup(70x00FFFF0x00FF000xFF0000) ;startup my base
$GUI 
_Apple_Draw_Gui(1901951"Launcher by kimboy."0xFFFFFF230) ;draw a gui
_Apple_Create_Function
("1° Program"80) ;0
_Apple_Create_Function
("2° Program"80) ;1
_Apple_Create_Function
("3° Program"80) ;2
_Apple_Create_Function
("4° Program"80) ;3
_Apple_Create_Function
("5° Program"80) ;4
_Apple_Create_Function
("Reset"80);6
_Apple_Create_Function
("Exit"80);7
 _Apple_State_Gui
(1$GUI)
_Apple_Enable_Up_Down()
;
Directory dei file da avviare
;Directory of files to run
$R1 
IniRead(@TempDir "\Pro_Loader\Pro1.ini","File","Directory","")
$R2 IniRead(@TempDir "\Pro_Loader\Pro2.ini","File","Directory","")
$R3 IniRead(@TempDir "\Pro_Loader\Pro3.ini","File","Directory","")
$R4 IniRead(@TempDir "\Pro_Loader\Pro4.ini","File","Directory","")
$R5 IniRead(@TempDir "\Pro_Loader\Pro5.ini","File","Directory","")
$R6 IniRead(@TempDir "\Pro_Loader\Pro6.ini","File","Directory","")
$R7 IniRead(@TempDir "\Pro_Loader\Pro7.ini","File","Directory","")
$R8 IniRead(@TempDir "\Pro_Loader\Pro8.ini","File","Directory","")
$R9 IniRead(@TempDir "\Pro_Loader\Pro9.ini","File","Directory","")
$R10 IniRead(@TempDir "\Pro_Loader\Pro10.ini","File","Directory","")
$R11 IniRead(@TempDir "\Pro_Loader\Pro11.ini","File","Directory","")
$R12 IniRead(@TempDir "\Pro_Loader\Pro12.ini","File","Directory","")
;
Nome dei label 
;Labels name
$RN1 
IniRead(@TempDir "\Pro_Loader\ProN1.ini","label","Name","")
$RN2 IniRead(@TempDir "\Pro_Loader\ProN2.ini","label","Name","")
$RN3 IniRead(@TempDir "\Pro_Loader\ProN3.ini","label","Name","")
$RN4 IniRead(@TempDir "\Pro_Loader\ProN4.ini","label","Name","")
$RN5 IniRead(@TempDir "\Pro_Loader\ProN5.ini","label","Name","")
$RN6 IniRead(@TempDir "\Pro_Loader\ProN6.ini","label","Name","")
$RN7 IniRead(@TempDir "\Pro_Loader\ProN7.ini","label","Name","")
$RN8 IniRead(@TempDir "\Pro_Loader\ProN8.ini","label","Name","")
$RN9 IniRead(@TempDir "\Pro_Loader\ProN9.ini","label","Name","")
$RN10 IniRead(@TempDir "\Pro_Loader\ProN10.ini","label","Name","")
$RN11 IniRead(@TempDir "\Pro_Loader\ProN11.ini","label","Name","")
$RN12 IniRead(@TempDir "\Pro_Loader\ProN12.ini","label","Name","")
If 
Not $R1 "" Then
   GUICtrlSetColor
($Lab[0], 0x008000)
   
GUICtrlSetData ($Lab[0],"Ready to start")
Else
   
GUICtrlSetColor($Lab[0], 0x000000)
   
GUICtrlSetData ($Lab[0],"Choose a file")
EndIf
If 
Not $RN1 "" Then
   GUICtrlSetData 
($NomFun[0],$RN1)
EndIf
If 
Not $R2 "" Then
   GUICtrlSetColor
($Lab[1], 0x008000)
   
GUICtrlSetData ($Lab[1],"Ready to start")
Else
   
GUICtrlSetColor($Lab[1], 0x000000)
   
GUICtrlSetData ($Lab[1],"Scegliere un file")
EndIf
If 
Not $RN2 "" Then
   GUICtrlSetData 
($NomFun[1],$RN2)
EndIf
If 
Not $R3 "" Then
   GUICtrlSetColor
($Lab[2], 0x008000)
   
GUICtrlSetData ($Lab[2],"Ready to start")
Else
   
GUICtrlSetColor($Lab[2], 0x000000)
   
GUICtrlSetData ($Lab[2],"Scegliere un file")
EndIf
If 
Not $RN3 "" Then
   GUICtrlSetData 
($NomFun[2],$RN3)
EndIf
If 
Not $R4 "" Then
   GUICtrlSetColor
($Lab[3], 0x008000)
   
GUICtrlSetData ($Lab[3],"Ready to start")
Else
   
GUICtrlSetColor($Lab[3], 0x000000)
   
GUICtrlSetData ($Lab[3],"Scegliere un file")
EndIf
If 
Not $RN4 "" Then
   GUICtrlSetData 
($NomFun[3],$RN4)
EndIf
If 
Not $R5 "" Then
   GUICtrlSetColor
($Lab[4], 0x008000)
   
GUICtrlSetData ($Lab[4],"Ready to start")
Else
   
GUICtrlSetColor($Lab[4], 0x000000)
   
GUICtrlSetData ($Lab[4],"Scegliere un file")
EndIf
If 
Not $RN5 "" Then
   GUICtrlSetData 
($NomFun[4],$RN5)
EndIf
GUICtrlSetBkColor ($NomFun[0],0xFF0000)
While 
True
    Sleep
(100)
WEnd

Func _0
($action)
    If 
$action 1 Then ;if the function gets enabled       
      $R1 
IniRead(@TempDir "\Pro_Loader\Pro1.ini","File","Directory","")
         If 
$R1 "" Then
            $F1 
FileOpenDialog ("Scegliere il file","","All files (*.*)",3)
            
IniWrite(@TempDir "\Pro_Loader\Pro1.ini","File","Directory",$F1)            
            
$NewName InputBox ("Launcher","Write a new name")
            
GUICtrlSetData ($NomFun[0],$NewName)
            
GUICtrlSetColor($Lab[0], 0x008000)
            
GUICtrlSetData ($Lab[0],"Ready to start")
            
IniWrite(@TempDir "\Pro_Loader\ProN1.ini","label","Name",$NewName)
            Else
            
ShellExecute($R1"""open")
         EndIf         
         ElseIf 
$action 0 Then ;if the function gets disabled
            $NewName 
InputBox ("Launcher","Write a new name")
            If @
error  Then
               MsgBox 
(0,"Launcher","Operazione annullata")
            Else
            
GUICtrlSetData ($NomFun[0],$NewName)
            
IniWrite(@TempDir "\Pro_Loader\ProN1.ini","label","Name",$NewName)
         EndIf         
    EndIf
EndFunc   ;==>_0
Func _1
($action)
    If 
$action 1 Then ;if the function gets enabled       
      $R2 
IniRead(@TempDir "\Pro_Loader\Pro2.ini","File","Directory","")
         If 
$R2 "" Then
            $F2 
FileOpenDialog ("Scegliere il file","","All files (*.*)",3)
            
IniWrite(@TempDir "\Pro_Loader\Pro2.ini","File","Directory",$F2)
            
            
$NewName2 InputBox ("Launcher","Write a new name")

            
GUICtrlSetData ($NomFun[1],$NewName2)
            
GUICtrlSetColor($Lab[1],0x008000)
            
GUICtrlSetData ($Lab[1],"Ready to start")
            
IniWrite(@TempDir "\Pro_Loader\ProN2.ini","label","Name",$NewName2)
            Else
            
ShellExecute($R2"""open")
         EndIf         
         ElseIf 
$action 0 Then ;if the function gets disabled
            $NewName2 
InputBox ("Launcher","Write a new name")
            If @
error  Then
               MsgBox 
(0,"Launcher","Operazione annullata")
            Else
            
GUICtrlSetData ($NomFun[1],$NewName2)
            
IniWrite(@TempDir "\Pro_Loader\ProN2.ini","label","Name",$NewName2)
         EndIf         
    EndIf
EndFunc   ;==>_1
Func _2
($action)
    If 
$action 1 Then ;if the function gets enabled       
      $R3 
IniRead(@TempDir "\Pro_Loader\Pro3.ini","File","Directory","")
         If 
$R3 "" Then
            $F3 
FileOpenDialog ("Scegliere il file","","All files (*.*)",3)
            
IniWrite(@TempDir "\Pro_Loader\Pro3.ini","File","Directory",$F3)
            
$NewName3 InputBox ("Launcher","Write a new name")
            
GUICtrlSetData ($NomFun[2],$NewName3)
            
GUICtrlSetColor($Lab[2], 0x008000)
            
GUICtrlSetData ($Lab[2],"Ready to start")
            
IniWrite(@TempDir "\Pro_Loader\ProN3.ini","label","Name",$NewName3)
            Else
            
ShellExecute($R3"""open")
         EndIf         
         ElseIf 
$action 0 Then ;if the function gets disabled
            $NewName3 
InputBox ("Launcher","Write a new name")
            If @
error  Then
               MsgBox 
(0,"Launcher","Operazione annullata")
            Else
            
GUICtrlSetData ($NomFun[2],$NewName3)
            
IniWrite(@TempDir "\Pro_Loader\ProN3.ini","label","Name",$NewName3)
         EndIf         
    EndIf
 
EndFunc   ;==>_2
Func _3
($action)
    If 
$action 1 Then ;if the function gets enabled       
      $R4 
IniRead(@TempDir "\Pro_Loader\Pro4.ini","File","Directory","")
         If 
$R4 "" Then
            $F4 
FileOpenDialog ("Scegliere il file","","All files (*.*)",3)
            
IniWrite(@TempDir "\Pro_Loader\Pro4.ini","File","Directory",$F4)            
            
$NewName4 InputBox ("Launcher","Write a new name")
            
GUICtrlSetData ($NomFun[3],$NewName4)
            
GUICtrlSetColor($Lab[3], 0x008000)
            
GUICtrlSetData ($Lab[3],"Ready to start")
            
IniWrite(@TempDir "\Pro_Loader\ProN4.ini","label","Name",$NewName4)
            Else
            
ShellExecute($R4"""open")
         EndIf         
         ElseIf 
$action 0 Then ;if the function gets disabled
            $NewName4 
InputBox ("Launcher","Write a new name")
            If @
error  Then
               MsgBox 
(0,"Launcher","Operazione annullata")
            Else
            
GUICtrlSetData ($NomFun[3],$NewName)
            
IniWrite(@TempDir "\Pro_Loader\ProN4.ini","label","Name",$NewName4)
         EndIf         
      EndIf
EndFunc
 Func _4
($action)
    If 
$action 1 Then ;if the function gets enabled       
      $R5 
IniRead(@TempDir "\Pro_Loader\Pro5.ini","File","Directory","")
         If 
$R5 "" Then
            $F5 
FileOpenDialog ("Scegliere il file","","All files (*.*)",3)
            
IniWrite(@TempDir "\Pro_Loader\Pro5.ini","File","Directory",$F5)            
            
$NewName5 InputBox ("Launcher","Write a new name")
            
GUICtrlSetData ($NomFun[4],$NewName5)
            
GUICtrlSetColor($Lab[4], 0x008000)
            
GUICtrlSetData ($Lab[4],"Ready to start")
            
IniWrite(@TempDir "\Pro_Loader\ProN5.ini","label","Name",$NewName5)
            Else
            
ShellExecute($R5"""open")
         EndIf         
         ElseIf 
$action 0 Then ;if the function gets disabled
            $NewName5 
InputBox ("Launcher","Write a new name")
            If 
$NewName5 "" Then
               GUICtrlSetData 
($Nomfun[4],"5° Program")
            Else
            
GUICtrlSetData ($NomFun[4],$NewName5)
            
IniWrite(@TempDir "\Pro_Loader\ProN4.ini","label","Name",$NewName5)
         EndIf         
      EndIf
EndFunc
Func _5
($action)
    If 
$action 1 Then ;if the function gets enabled     
      $quest 
MsgBox(262180,"Launcher","Are you sure to reset links?")       
       If 
$quest 6 Then
            FileDelete 
(@TempDir "\Pro_Loader\Pro1.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro2.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro3.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro4.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro5.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro6.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro7.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro8.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro9.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro10.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro11.ini")
            
FileDelete (@TempDir "\Pro_Loader\Pro12.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN1.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN2.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN3.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN4.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN5.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN6.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN7.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN8.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN9.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN10.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN11.ini")
            
FileDelete (@TempDir "\Pro_Loader\ProN12.ini")
            
MsgBox (0,"Launcher","Datas succesfully deleted")
            
GUICtrlSetData ($NomFun[0],"1° Program")
            
GUICtrlSetData ($NomFun[1],"2° Program")
            
GUICtrlSetData ($NomFun[2],"3° Program")    
            
GUICtrlSetData ($NomFun[3],"3° Program")    
            
GUICtrlSetData ($NomFun[4],"3° Program")    
            
GUICtrlSetColor($Lab[0], 0x000000)
            
GUICtrlSetData ($Lab[0],"Scegliere un file")
            
GUICtrlSetColor($Lab[1], 0x000000)
            
GUICtrlSetData ($Lab[1],"Scegliere un file")
            
GUICtrlSetColor($Lab[2], 0x000000)
            
GUICtrlSetData ($Lab[2],"Scegliere un file")
            
GUICtrlSetColor($Lab[3], 0x000000)
            
GUICtrlSetData ($Lab[3],"Scegliere un file")
            
GUICtrlSetColor($Lab[4], 0x000000)
            
GUICtrlSetData ($Lab[4],"Scegliere un file")
         Else
            
MsgBox (0,"Launcher","Datas don't deleted")
         EndIf
      ElseIf 
$action 0 Then ;if the function gets disabled
         MsgBox 
(0,"Launcher","You can't change ""Reset""'s name")
    EndIf
 
EndFunc   ;==>_3
 Func _6
($action)
   If 
$action 1 Then ;if the function gets enabled
      Sleep 
(600)
      Exit
      ElseIf 
$action 0 Then ;if the function gets disabled
         MsgBox 
(0,"Launcher","You can't change ""Exit""'s name")
      EndIf
   
EndFunc
Func _SH
()
    If 
$Toggled  1  Then
      _Apple_State_Gui
(0$GUI)      
      
$Toggled 0
    
Elseif $Toggled 0 Then
      _Apple_State_Gui
(1$GUI)
      
$Toggled 1
    
EndIf
EndFunc 
08/26/2013 19:56 alpines#2
Using Arrays and Loops would make this code much shorter.
08/27/2013 17:00 FacePalmMan#3
Quote:
Originally Posted by alpines View Post
Using Arrays and Loops would make this code much shorter.
and easier to configure