tjestr Posted August 12, 2007 Share Posted August 12, 2007 (edited) hello, i want to write a tiny tool to install software to our citrix farm servers. to keep the installation synchronous on each server i've scripted an unattended installation for each software to be installed. now i want to create a gui for better usability. To check if a software is already installed i do a "if fileexist". The software which is already installed should be greyed out in the gui. if is select the button "Select all" all non greyed out checkboxes should be cheked. This works but the way it works is stupid i think but i don't know how to do it better. anybody some suggestions on how to do the script better? expandcollapse popup#include <GUIConstants.au3> Global $p_nav210 = ("D:\nav210.txt") Global $p_nav310 = ("D:\nav310.txt") Global $p_nav410 = ("D:\nav410.txt") Dim $appchkbox[1] GUICreate ("Citrix Farm Software Installation (Navision)") $selectall = GUICtrlCreateButton ("Select all", 20, 250, 90) $deselectall = GUICtrlCreateButton ("Deselect all", 120, 250, 90) $binstall = GUICtrlCreateButton ("Install", 20, 280, 60) $bexit = GUICtrlCreateButton ("Exit", 90, 280, 60) $apps = stringsplit("Navi 2.10|Navi 3.10|Navi 4.10","|") Redim $appchkbox[$apps[0] +1] $top = 10 For $i = 1 to $apps[0] $top = $top + 20 $appchkbox[$i] = GUICtrlCreateCheckbox($apps[$i],10,$top) Next Func nav210 () If FileExists ($p_nav210) Then GuiCtrlSetState ($appchkbox[1], $GUI_DISABLE) GUICtrlSetState($appchkbox[1],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[1], $GUI_UNCHECKED) EndIf EndFunc Func nav310 () If FileExists ($p_nav310) Then GuiCtrlSetState ($appchkbox[2], $GUI_DISABLE) GUICtrlSetState($appchkbox[2],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[2], $GUI_UNCHECKED) EndIf EndFunc Func nav410 () If FileExists ($p_nav410) Then GuiCtrlSetState ($appchkbox[3], $GUI_DISABLE) GUICtrlSetState($appchkbox[3],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[3], $GUI_UNCHECKED) EndIf EndFunc Func install() If Guictrlread($appchkbox[1]) = $GUI_CHECKED then Run ("notepad.exe") If Guictrlread($appchkbox[2]) = $GUI_CHECKED then Run ("mspaint.exe") If Guictrlread($appchkbox[3]) = $GUI_CHECKED then Run ("mstsc.exe") EndFunc Call ("nav210") Call ("nav310") Call ("nav410") GUISetState () ; ------------------------------------------------------------------------ While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $binstall Call ("install") Case $bexit Exit Case $deselectall For $i = 1 to $apps[0] GUICtrlSetState($appchkbox[$i],$GUI_UNCHECKED) Next Case $selectall for $i = 1 to $apps[0] GUICtrlSetState($appchkbox[$i],$GUI_CHECKED) Next Call ("nav210") Call ("nav310") Call ("nav410") EndSwitch Wend Edited August 12, 2007 by tjestr Link to comment Share on other sites More sharing options...
Tiger Posted August 12, 2007 Share Posted August 12, 2007 It is better, when you put all no installed programs in the list My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
tjestr Posted August 12, 2007 Author Share Posted August 12, 2007 At the moment all programs defined in $appchkbox are listed in the gui. i just want to optimize the code. and of course i want to learn on how to do it better. Link to comment Share on other sites More sharing options...
Tiger Posted August 12, 2007 Share Posted August 12, 2007 (edited) OK. I look the script tomorrow and in the evening I post the scriptEdit: Can you post the files "D:\nav210.txt", "D:\nav310.txt", "D:\nav410.txt" Edited August 12, 2007 by Tiger My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
tjestr Posted August 12, 2007 Author Share Posted August 12, 2007 (edited) That are just test files. In the end these files are indecators if an application is installed or not. Edited August 12, 2007 by tjestr Link to comment Share on other sites More sharing options...
Tiger Posted August 12, 2007 Share Posted August 12, 2007 Have you an example? My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
tjestr Posted August 12, 2007 Author Share Posted August 12, 2007 You do not need an example. just take a file you want. it just checks if a application is installed or not. Link to comment Share on other sites More sharing options...
The Kandie Man Posted August 13, 2007 Share Posted August 13, 2007 Here, I played around with it a bit. Here is a version that behaves similarly to your original script:expandcollapse popup#include <GUIConstants.au3> Global $p_nav210 = ("D:\nav210.txt");Don't need the parenthesis here, but i will leave it because it looks nice Global $p_nav310 = ("D:\nav310.txt") Global $p_nav410 = ("D:\nav410.txt") GUICreate ("Citrix Farm Software Installation (Navision)",210,280) $selectall = GUICtrlCreateButton ("Select all", 10, 220, 90) $deselectall = GUICtrlCreateButton ("Deselect all", 110, 220, 90) $binstall = GUICtrlCreateButton ("Install", 10, 250, 60) $bexit = GUICtrlCreateButton ("Exit", 80, 250, 60) ;~ $apps = stringsplit("Navi 2.10|Navi 3.10|Navi 4.10","|"); Don't need to do this Dim $apps[3] = ["Navi 2.10", "Navi 3.10", "Navi 4.10"] Dim $appchkbox[Ubound($apps)];Ubound gets the number of elements in an array Dim $top = 10 For $i = 0 to Ubound($apps)-1 $appchkbox[$i] = GUICtrlCreateCheckbox($apps[$i],10,$top) $top += 20 ;The += operator simplifies things by simply adding 20 to the variable Next ;Unlike most programming and scripting languages, functions do not have to be previously declared before calling them. They just have to be somewhere in the script. nav210();Try not to use call. Simply use the function name with parenthesis. Call is used for calling function names dynamically using a string. nav310() nav410() GUISetState () ; ------------------------------------------------------------------------ While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $binstall install() Case $bexit Exit Case $deselectall For $i = 0 to Ubound($apps)-1 GUICtrlSetState($appchkbox[$i],$GUI_UNCHECKED) Next Case $selectall For $i = 0 to Ubound($apps)-1 ;~ ConsoleWrite("State="&GUICtrlGetState($appchkbox[$i])&@LF) ;~ ConsoleWrite("$GUI_ENABLE + $GUI_UNCHECKED + $GUI_SHOW = " & $GUI_ENABLE + $GUI_UNCHECKED + $GUI_SHOW & @LF) If GUICtrlGetState($appchkbox[$i]) <> 144 Then GUICtrlSetState($appchkbox[$i],$GUI_CHECKED) ; = $GUI_ENABLE Then GUICtrlSetState($appchkbox[$i],$GUI_CHECKED) Next ;nav210() ;nav310() ;nav410() EndSwitch Wend ;~ ;In autoit, we generally place functions at the bottom of ths script. We just do and it increases the readability of how the main thread is actually going about things. Func nav210 () If FileExists ($p_nav210) Then GuiCtrlSetState ($appchkbox[0], $GUI_DISABLE) GUICtrlSetState($appchkbox[0],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[0], $GUI_UNCHECKED) EndIf EndFunc Func nav310 () If FileExists ($p_nav310) Then GuiCtrlSetState ($appchkbox[1], $GUI_DISABLE) GUICtrlSetState($appchkbox[1],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[1], $GUI_UNCHECKED) EndIf EndFunc Func nav410 () If FileExists ($p_nav410) Then GuiCtrlSetState ($appchkbox[2], $GUI_DISABLE) GUICtrlSetState($appchkbox[2],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[2], $GUI_UNCHECKED) EndIf EndFunc Func install() If Guictrlread($appchkbox[0]) = $GUI_CHECKED then Run ("notepad.exe") If Guictrlread($appchkbox[1]) = $GUI_CHECKED then Run ("mspaint.exe") If Guictrlread($appchkbox[2]) = $GUI_CHECKED then Run ("cmd.exe") EndFuncoÝ÷ Øw«z+az»Þ®È¨ØZµÚ²}ýµëÞÊÞj×ç!yÉ£zk"~+[zX½ë-«mëޮȨ¬jZÞiÜyéâËZWjëh×6#include <GUIConstants.au3> Global $p_nav210 = ("D:\nav210.txt");Don't need the parenthesis here, but i will leave it because it looks nice Global $p_nav310 = ("D:\nav310.txt") Global $p_nav410 = ("D:\nav410.txt") GUICreate ("Citrix Farm Software Installation (Navision)",210,280) $selectall = GUICtrlCreateButton ("Select all", 10, 220, 90) $deselectall = GUICtrlCreateButton ("Deselect all", 110, 220, 90) $binstall = GUICtrlCreateButton ("Install", 10, 250, 60) $bexit = GUICtrlCreateButton ("Exit", 80, 250, 60) ;~ $apps = stringsplit("Navi 2.10|Navi 3.10|Navi 4.10","|"); Don't need to do this Dim $apps[3] = ["Navi 2.10", "Navi 3.10", "Navi 4.10"] Dim $ap_navXXX[3] = ["D:\nav210.txt","D:\nav310.txt","D:\nav410.txt"];Make sure they are in the same order as the above array Dim $appchkbox[Ubound($apps)];Ubound gets the number of elements in an array Dim $top = 10 ;~ Dim $i_Counter = 0 For $i = 0 to Ubound($apps)-1 If Not FileExists($ap_navXXX[$i]) Then $appchkbox[$i] = GUICtrlCreateCheckbox($apps[$i],10,$top) $top += 20 ;The += operator simplifies things by simply adding 20 to the variable ;~ $i_Counter += 1 Endif Next ;~ Redim $appchkbox[$i_Counter] #cs For $i = 0 to Ubound($apps)-1 $appchkbox[$i] = GUICtrlCreateCheckbox($apps[$i],10,$top) $top += 20 ;The += operator simplifies things by simply adding 20 to the variable Next #ce #cs ;Unlike most programming and scripting languages, functions do not have to be previously declared before calling them. They just have to be somewhere in the script. nav210();Try not to use call. Simply use the function name with parenthesis. Call is used for calling function names dynamically using a string. nav310() nav410() #ce GUISetState () ; ------------------------------------------------------------------------ While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $binstall install() Case $bexit Exit Case $deselectall For $i = 0 to Ubound($appchkbox)-1 GUICtrlSetState($appchkbox[$i],$GUI_UNCHECKED) Next Case $selectall For $i = 0 to Ubound($appchkbox)-1 ;~ ConsoleWrite("State="&GUICtrlGetState($appchkbox[$i])&@LF) ;~ ConsoleWrite("$GUI_ENABLE + $GUI_UNCHECKED + $GUI_SHOW = " & $GUI_ENABLE + $GUI_UNCHECKED + $GUI_SHOW & @LF) If GUICtrlGetState($appchkbox[$i]) <> 144 Then GUICtrlSetState($appchkbox[$i],$GUI_CHECKED) ; = $GUI_ENABLE Then GUICtrlSetState($appchkbox[$i],$GUI_CHECKED) Next ;nav210() ;nav310() ;nav410() EndSwitch Wend ;~ ;In autoit, we generally place functions at the bottom of ths script. We just do and it increases the readability of how the main thread is actually going about things. Func nav210 () If FileExists ($p_nav210) Then GuiCtrlSetState ($appchkbox[0], $GUI_DISABLE) GUICtrlSetState($appchkbox[0],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[0], $GUI_UNCHECKED) EndIf EndFunc Func nav310 () If FileExists ($p_nav310) Then GuiCtrlSetState ($appchkbox[1], $GUI_DISABLE) GUICtrlSetState($appchkbox[1],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[1], $GUI_UNCHECKED) EndIf EndFunc Func nav410 () If FileExists ($p_nav410) Then GuiCtrlSetState ($appchkbox[2], $GUI_DISABLE) GUICtrlSetState($appchkbox[2],$GUI_UNCHECKED) Else GuiCtrlSetState ($appchkbox[2], $GUI_UNCHECKED) EndIf EndFunc Func install() If Guictrlread($appchkbox[0]) = $GUI_CHECKED then Run ("notepad.exe") If Guictrlread($appchkbox[1]) = $GUI_CHECKED then Run ("mspaint.exe") If Guictrlread($appchkbox[2]) = $GUI_CHECKED then Run ("cmd.exe") EndFunc Hope that helps you a bit. - The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
tjestr Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) Thank you very much Kandy Man! i appreciate your work! is there any possibility to shorten/optimize the code for better reading? (e.g. the func fe_ or the func si_) and how to implement a progress bar into the installation progress? expandcollapse popup#include <GUIConstants.au3> ; --- For testing purposes i choose the following files ------ Global $pp_nav356a = ("D:\nav210.txt") Global $pp_nav201b = ("D:\nav310.txt") Global $pp_nav260f = ("D:\nav410.txt") Global $pp_nav310a = ("D:\nav410.txt") Global $pp_nav360 = ("D:\nav410.txt") Global $pp_nav370b = ("D:\nav410.txt") Global $pp_nav370 = ("D:\nav410.txt") Global $pp_nav370hf13 = ("D:\nav410.txt") Global $pp_nav400sp3 = ("D:\nav410.txt") Global $pp_nav400 = ("D:\nav410.txt") Global $pp_nav400sp1 = ("D:\nav410.txt") Global $pp_nav400sp2 = ("D:\nav410.txt") Global $pp_nav500 = ("D:\nav410.txt") Global $pp_ccaps = ("D:\nav410.txt") Global $pp_fte = ("D:\nav410.txt") ; ------------- Creating the GUI ---------------------------------------- GUICreate ("Citrix Farm Software Installation (Navision)",300,400) $selectall = GUICtrlCreateButton ("Select all", 10, 340, 90) $deselectall = GUICtrlCreateButton ("Deselect all", 110, 340, 90) $binstall = GUICtrlCreateButton ("Install", 10, 370, 60) $bexit = GUICtrlCreateButton ("Exit", 80, 370, 60) Dim $apps[15] = ["Navision 3.56A", "Navision 2.01B", "Navision 2.60F", "Navision 3.10A", "Navision 3.60", "Navision 3.70B", "Navision 3.70", "Navision 3.70 HF13", "Navision 4.00 SP3", "Navision 4.00", "Navision 4.00 SP1", "Navision 4.00 SP2", "Navision 5.00", "CCAPS", "Fließtexteditor"] Dim $appchkbox[Ubound($apps)] Dim $top = 10 For $i = 0 to Ubound($apps)-1 $appchkbox[$i] = GUICtrlCreateCheckbox($apps[$i],10,$top) $top += 20 Next ; ------------- Check if Software is already installed ------------------- fe_nav356a() fe_nav201b() fe_nav260f() fe_nav310a() fe_nav360() fe_nav370b() fe_nav370() fe_nav370hf13() fe_nav400sp3() fe_nav400() fe_nav400sp1() fe_nav400sp2() fe_nav500() fe_ccaps() fe_fte() GUISetState () ; ------------------------------------------------------------------------ While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $binstall install() Case $bexit Exit Case $deselectall For $i = 0 to Ubound($apps)-1 GUICtrlSetState($appchkbox[$i],$GUI_UNCHECKED) Next Case $selectall For $i = 0 to Ubound($apps)-1 If GUICtrlGetState($appchkbox[$i]) <> 144 Then GUICtrlSetState($appchkbox[$i],$GUI_CHECKED) Next EndSwitch Wend ; ------------- Check if Software is already installed ------------------- Func fe_nav356a () If FileExists ($pp_nav356a) Then GuiCtrlSetState ($appchkbox[0], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[0], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav201b () If FileExists ($pp_nav201b) Then GuiCtrlSetState ($appchkbox[1], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[1], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav260f () If FileExists ($pp_nav260f) Then GuiCtrlSetState ($appchkbox[2], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[2], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav310a () If FileExists ($pp_nav310a) Then GuiCtrlSetState ($appchkbox[3], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[3], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav360 () If FileExists ($pp_nav360) Then GuiCtrlSetState ($appchkbox[4], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[4], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav370b () If FileExists ($pp_nav370b) Then GuiCtrlSetState ($appchkbox[5], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[5], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav370 () If FileExists ($pp_nav370) Then GuiCtrlSetState ($appchkbox[6], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[6], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav370hf13 () If FileExists ($pp_nav370hf13) Then GuiCtrlSetState ($appchkbox[7], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[7], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav400sp3 () If FileExists ($pp_nav400sp3) Then GuiCtrlSetState ($appchkbox[8], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[8], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav400 () If FileExists ($pp_nav400) Then GuiCtrlSetState ($appchkbox[9], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[9], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav400sp1 () If FileExists ($pp_nav400sp1) Then GuiCtrlSetState ($appchkbox[10], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[10], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav400sp2 () If FileExists ($pp_nav400sp2) Then GuiCtrlSetState ($appchkbox[11], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[11], $GUI_UNCHECKED) EndIf EndFunc Func fe_nav500 () If FileExists ($pp_nav500) Then GuiCtrlSetState ($appchkbox[12], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[12], $GUI_UNCHECKED) EndIf EndFunc Func fe_ccaps () If FileExists ($pp_ccaps) Then GuiCtrlSetState ($appchkbox[13], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[13], $GUI_UNCHECKED) EndIf EndFunc Func fe_fte () If FileExists ($pp_fte) Then GuiCtrlSetState ($appchkbox[14], $GUI_DISABLE) Else GuiCtrlSetState ($appchkbox[14], $GUI_UNCHECKED) EndIf EndFunc ; ------------- Unattended Software packages ---------------------------- ; ------------- for testing purposes just msgboxes ----------------------- Func si_356a () MsgBox(0, "Installing Software", "Installing " & $apps[0]) EndFunc Func si_201b () MsgBox(0, "Installing Software", "Installing " & $apps[1]) EndFunc Func si_260f () MsgBox(0, "Installing Software", "Installing " & $apps[2]) EndFunc Func si_310a () MsgBox(0, "Installing Software", "Installing " & $apps[3]) EndFunc Func si_360 () MsgBox(0, "Installing Software", "Installing " & $apps[4]) EndFunc Func si_370b () MsgBox(0, "Installing Software", "Installing " & $apps[5]) EndFunc Func si_370 () MsgBox(0, "Installing Software", "Installing " & $apps[6]) EndFunc Func si_370hf13 () MsgBox(0, "Installing Software", "Installing " & $apps[7]) EndFunc Func si_400sp3 () MsgBox(0, "Installing Software", "Installing " & $apps[8]) EndFunc Func si_400 () MsgBox(0, "Installing Software", "Installing " & $apps[9]) EndFunc Func si_400sp1 () MsgBox(0, "Installing Software", "Installing " & $apps[10]) EndFunc Func si_400sp2 () MsgBox(0, "Installing Software", "Installing " & $apps[11]) EndFunc Func si_500 () MsgBox(0, "Installing Software", "Installing " & $apps[12]) EndFunc Func si_ccaps () MsgBox(0, "Installing Software", "Installing " & $apps[13]) EndFunc Func si_fte () MsgBox(0, "Installing Software", "Installing " & $apps[14]) EndFunc ; ------------- Installing selected Software ---------------------------- Func install() If Guictrlread($appchkbox[0]) = $GUI_CHECKED then si_356a () If Guictrlread($appchkbox[1]) = $GUI_CHECKED then si_201b () If Guictrlread($appchkbox[2]) = $GUI_CHECKED then si_260f () If Guictrlread($appchkbox[3]) = $GUI_CHECKED then si_310a () If Guictrlread($appchkbox[4]) = $GUI_CHECKED then si_360 () If Guictrlread($appchkbox[5]) = $GUI_CHECKED then si_370b () If Guictrlread($appchkbox[6]) = $GUI_CHECKED then si_370 () If Guictrlread($appchkbox[7]) = $GUI_CHECKED then si_370hf13 () If Guictrlread($appchkbox[8]) = $GUI_CHECKED then si_400sp3 () If Guictrlread($appchkbox[9]) = $GUI_CHECKED then si_400 () If Guictrlread($appchkbox[10]) = $GUI_CHECKED then si_400sp1 () If Guictrlread($appchkbox[11]) = $GUI_CHECKED then si_400sp2 () If Guictrlread($appchkbox[12]) = $GUI_CHECKED then si_500 () If Guictrlread($appchkbox[13]) = $GUI_CHECKED then si_ccaps () If Guictrlread($appchkbox[14]) = $GUI_CHECKED then si_fte () EndFunc Edited August 13, 2007 by tjestr Link to comment Share on other sites More sharing options...
ResNullius Posted August 13, 2007 Share Posted August 13, 2007 is there any possibility to shorten/optimize the code for better reading? (e.g. the func fe_ or the func si_)This looks like an ideal situation for the application of the scripting dictionary object. It also makes the code easier to maintain for adding & removing applications from the list to check for. The following dictionary code is lifted from the inimitable Mr. gafrost http://www.autoitscript.com/forum/index.ph...st&p=352256 I probably haven't done the cleanest job with it, but it's easier to manage then writing all the check functions separately... expandcollapse popup;dictionary functions from gafrost http://www.autoitscript.com/forum/index.php?s=&showtopic=47048&view=findpost&p=352256 ; #include <GUIConstants.au3> Global $oDictionary, $oMyError ; Create dictionary object $oDictionary = _InitDictionary() $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Initialize a COM error handler Global $vKey, $sItem, $sMsg ; Add keys with items _AddItem("Navision 3.56A", "D:\nav210.txt") _AddItem("Navision 2.01B", "D:\nav310.txt") _AddItem("Navision 2.60F", "D:\nav410.txt") _AddItem("Navision 3.10A", "D:\nav410.txt") _AddItem("Navision 3.60", "D:\nav410.txt") _AddItem("Navision 3.70B", "D:\nav410.txt") _AddItem("Navision 3.70", "D:\nav410.txt") _AddItem("Navision 3.70 HF13", "D:\nav410.txt") _AddItem("Navision 4.00 SP3", "D:\nav410.txt") _AddItem("Navision 4.00", "D:\nav410.txt") _AddItem("Navision 4.00 SP1", "D:\nav410.txt") _AddItem("Navision 4.00 SP2", "D:\nav410.txt") _AddItem("Navision 5.00", "D:\nav410.txt") _AddItem("CCAPS", "D:\nav410.txt") _AddItem("Fließtexteditor", "D:\nav410.txt") ; ------------- Creating the GUI ---------------------------------------- GUICreate("Citrix Farm Software Installation (Navision)", 300, 400) $selectall = GUICtrlCreateButton("Select all", 10, 340, 90) $deselectall = GUICtrlCreateButton("Deselect all", 110, 340, 90) $binstall = GUICtrlCreateButton("Install", 10, 370, 60) $bexit = GUICtrlCreateButton("Exit", 80, 370, 60) $items = _ItemCount() Dim $appchkbox[$items], $top = 10, $i = 0 For $vKey In $oDictionary $appchkbox[$i] = GUICtrlCreateCheckbox($vKey, 10, $top) If FileExists(_Item($vKey)) Then GUICtrlSetState($appchkbox[$i], $GUI_DISABLE) Else GUICtrlSetState($appchkbox[$i], $GUI_UNCHECKED) EndIf $top += 20 $i += 1 Next GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $binstall install () Case $bexit Exit Case $deselectall For $i = 0 To $items - 1 GUICtrlSetState($appchkbox[$i], $GUI_UNCHECKED) Next Case $selectall For $i = 0 To $items - 1 If GUICtrlGetState($appchkbox[$i]) <> 144 Then GUICtrlSetState($appchkbox[$i], $GUI_CHECKED) Next EndSwitch WEnd $oDictionary.RemoveAll () MsgBox(0x0, 'Items Count', _ItemCount(), 3) Func _InitDictionary() Return ObjCreate("Scripting.Dictionary") EndFunc ;==>_InitDictionary ; Adds a key and item pair to a Dictionary object. Func _AddItem($v_key, $v_item) $oDictionary.ADD ($v_key, $v_item) If @error Then Return SetError(1, 1, -1) EndFunc ;==>_AddItem ; Returns true if a specified key exists in the Dictionary object, false if it does not. Func _ItemExists($v_key) Return $oDictionary.Exists ($v_key) EndFunc ;==>_ItemExists ; Returns an item for a specified key in a Dictionary object Func _Item($v_key) Return $oDictionary.Item ($v_key) EndFunc ;==>_Item ; Sets an item for a specified key in a Dictionary object Func _ChangeItem($v_key, $v_item) $oDictionary.Item ($v_key) = $v_item EndFunc ;==>_ChangeItem ; Sets a key in a Dictionary object. Func _ChangeKey($v_key, $v_newKey) $oDictionary.Key ($v_key) = $v_newKey EndFunc ;==>_ChangeKey ; Removes a key, item pair from a Dictionary object. Func _ItemRemove($v_key) $oDictionary.Remove ($v_key) If @error Then Return SetError(1, 1, -1) EndFunc ;==>_ItemRemove ; Returns the number of items in a collection or Dictionary object. Func _ItemCount() Return $oDictionary.Count EndFunc ;==>_ItemCount ; Returns an array containing all the items in a Dictionary object Func _GetItems() Return $oDictionary.Items EndFunc ;==>_GetItems ; This is my custom defined error handler Func MyErrFunc() Local $err = $oMyError.number If $err = 0 Then $err = -1 SetError($err) ; to check for after this function returns EndFunc ;==>MyErrFunc Func _DebugPrint($s_Text) ConsoleWrite( _ "!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_Text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint Of course, you could UDF all the scripting dictionary functions into an include... Link to comment Share on other sites More sharing options...
tjestr Posted August 13, 2007 Author Share Posted August 13, 2007 How do i go on with my install function? This one will not work anymore.. Func install() If Guictrlread($appchkbox[0]) = $GUI_CHECKED then si_356a () If Guictrlread($appchkbox[1]) = $GUI_CHECKED then si_201b () If Guictrlread($appchkbox[2]) = $GUI_CHECKED then si_260f () If Guictrlread($appchkbox[3]) = $GUI_CHECKED then si_310a () If Guictrlread($appchkbox[4]) = $GUI_CHECKED then si_360 () If Guictrlread($appchkbox[5]) = $GUI_CHECKED then si_370b () If Guictrlread($appchkbox[6]) = $GUI_CHECKED then si_370 () If Guictrlread($appchkbox[7]) = $GUI_CHECKED then si_370hf13 () If Guictrlread($appchkbox[8]) = $GUI_CHECKED then si_400sp3 () If Guictrlread($appchkbox[9]) = $GUI_CHECKED then si_400 () If Guictrlread($appchkbox[10]) = $GUI_CHECKED then si_400sp1 () If Guictrlread($appchkbox[11]) = $GUI_CHECKED then si_400sp2 () If Guictrlread($appchkbox[12]) = $GUI_CHECKED then si_500 () If Guictrlread($appchkbox[13]) = $GUI_CHECKED then si_ccaps () If Guictrlread($appchkbox[14]) = $GUI_CHECKED then si_fte () EndFunc Link to comment Share on other sites More sharing options...
tjestr Posted August 14, 2007 Author Share Posted August 14, 2007 No idea how to do that? Link to comment Share on other sites More sharing options...
ResNullius Posted August 14, 2007 Share Posted August 14, 2007 No idea how to do that?OK, I think you should scrap the data dictionary idea. Even though we could setup another dictionary for the App name and the install function, it's going to get a little messy. We could also use a 3 dimensional array, but with that many elements it too is probably going to become a little unwieldy. I suggest you look at storing the app names, installed test file, and setup file names in an Ini file and have your script read from that to create your GUI and loop your setups. An ini will also make it easier to mainatin the installation base as you'll only need to edit the Ini when you want to add/remove Applications from the process and can leave your main script as is. I imagine the Ini would be structured something like [Navision 3.56A] Installed = D:\nav210.txt Setup = si_356a [Navision 2.01B] Installed = D:\nav310.txt Setup = si_201b [Navision 2.60F] Installed = D:\nav410.txt Setup = si_260f Have a go and if you cant work it out then I'll see if I have some time later. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now