#include #include #include #include #include #include #include #include #include #include #Include Local $widthCell, $msg, $iOldOpt Dim $Display1 = "" Dim $sPathAUT = 'C:\Data\AUT.xls' Dim $sPathUSERS = 'C:\Data\USERS.xls' Dim $sPathENVS = 'C:\Data\ENVS.xls' Dim $oExcel1 = _ExcelBookOpen($sPathAUT, 0) Dim $oExcel2 = _ExcelBookOpen($sPathUSERS, 0) Dim $oExcel3 = _ExcelBookOpen($sPathENVS, 0) Dim $aArrayAUT = _ExcelReadSheetToArray($oExcel1) Dim $aArrayUSER = _ExcelReadSheetToArray($oExcel2) Dim $aArrayENVS = _ExcelReadSheetToArray($oExcel3) _ExcelBookClose($oExcel1, 0) _ExcelBookClose($oExcel3, 0) Dim $cellcount = 0 Dim $sCellValue = '' For $i = 1 to 256 $sCellValue = _ExcelReadCell($oExcel2, $i, 1) If $sCellValue = '' Then ;MsgBox(0x40, 'Cell count is ', $i) $cellcount = $i $i = 256 EndIf Next $cellcount = $cellcount - 1 Dim $sStr = '' For $i = 1 To $aArrayAUT[0][0] For $j = 1 To $aArrayAUT[0][1] If $aArrayAUT[$i][$j] <> "" Then $sStr &= $aArrayAUT[$i][$j] & '|' Next Next $sStr = StringTrimRight($sStr, 1) Dim $sStr2 = '' For $i = 1 to $cellcount $sStr2 &= _ExcelReadCell($oExcel2, $i, 1) & '|' Next _ExcelBookClose($oExcel2, 0) ;Dim $sStr2 = '' ;For $i = 1 To $aArrayUSER[0][0] ; For $j = 1 To $aArrayUSER[0][1] ; If $aArrayUSER[$i][$j] <> "" Then $sStr2 &= $aArrayUSER[$i][$j] & '|' ; Next ;Next $sStr2 = StringTrimRight($sStr2, 1) Dim $sStr3 = '' For $i = 1 To $aArrayENVS[0][0] For $j = 1 To $aArrayENVS[0][1] If $aArrayENVS[$i][$j] <> "" Then $sStr3 &= $aArrayENVS[$i][$j] & '|' Next Next $sStr3 = StringTrimRight($sStr3, 1) Global $aArray[6] For $i = 1 to 5 $aArray[$i] = "Something from Excel " & $i - 1 Next $aArray[0] = 5 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Rundata Default Selection", 633, 447, 289, 213) $Group1 = GUICtrlCreateGroup("User Profile Selection", 8, 0, 585, 105) GUICtrlSetFont(-1, 10, 400, 0, "Verdana") GUICtrlCreateGroup("1", -99, -99, 1, 1) GUISetBkColor(0xA6CAF0) ;$Label1 = GUICtrlCreateLabel(" Please Select ", 16, 18, 216, 18) ;GUICtrlSetFont(-1, 9, 800, 0, "Verdana") ;GUICtrlSetColor(-1, 0x000080) $Label1 = GUICtrlCreateLabel("Application to test", 16, 36, 216, 18) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") GUICtrlSetColor(-1, 0x000080) $AUT = GUICtrlCreateCombo("", 32, 56, 75, 25) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") GUICtrlSetData($AUT, $sStr ) $Label2 = GUICtrlCreateLabel("Please Select User", 158, 36, 128, 18) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") GUICtrlSetColor(-1, 0x000080) $USER = GUICtrlCreateCombo("", 158, 56, 115, 25) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") GUICtrlSetData($USER, $sStr2 ) $Label3 = GUICtrlCreateLabel("Please Select Environment", 295, 24, 128, 36) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") GUICtrlSetColor(-1, 0x000080) $ENVS = GUICtrlCreateCombo("", 295, 56, 115, 25) GUICtrlSetFont(-1, 9, 400, 0, "Verdana") GUICtrlSetData($ENVS, $sStr3 ) $Checkbox1 = GUICtrlCreateCheckbox("Online?", 475, 56, 97, 17) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") $OK = GUICtrlCreateButton("OK", 32, 200, 75, 25, 0) GUISetState() #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Label1 Case $AUT $DisplayAUT = GUICtrlRead($AUT) ;MsgBox(0x40, 'Combo Box AUT ', $Display) Case $USER $DisplayUSER = GUICtrlRead($USER) ;MsgBox(0x40, 'Combo Box User ', $Display1) Case $ENVS $DisplayENV = GUICtrlRead($ENVS) ;MsgBox(0x40, 'Combo Box User ', $Display1) ;MsgBox(0x40, 'Combo Box Items', GUICtrlRead($ENVS)) ;MsgBox(0x40, 'Combo Box ENVS ', $Display2) Case $Checkbox1 $Checkboxonline = GUICtrlRead($Checkbox1) If $Checkboxonline = 1 Then ;MsgBox(0x40, 'Check Box is on', $Checkboxonline ,10) EndIf Case $OK MsgBox(0x40, 'Get out', $Checkboxonline ,10) ;######################################################### Global $aArray[6] For $i = 1 to 5 $aArray[$i] = "Something from Excel " & $i - 1 Next $aArray[0] = 5 ; Create a GUI ;GUICtrlSetState(-1, $GUI_DISABLE + $GUI_HIDE ) $hGUI = GUICreate("MultiSelect ListBox", 633, 447, 289, 213) $Label3 = GUICtrlCreateLabel("The Selected Environment,User and Application to test are ", 295, 24, 368, 36) $LabelAUT = GUICtrlCreateLabel("Environment : " & $DisplayENV , 295, 48, 168, 36) $LabelAUT1 = GUICtrlCreateLabel("User: " & $DisplayUSER , 295, 72, 168, 36) $LabelAUT2 = GUICtrlCreateLabel("Application: " & $DisplayAUT, 295, 96, 168, 36) ;$hGUI = GUICreate("MultiSelect ListBox", 300, 250) $hListBox = _GUICtrlListBox_Create ($hGUI, "", 10, 10, 280, 180, $LBS_EXTENDEDSEL) $hButton_Select = GUICtrlCreateButton("Select", 30, 210, 80, 30) $hButton_Clear = GUICtrlCreateButton("Clear", 190, 210, 80, 30) $hButton_OK = GUICtrlCreateButton("OK", 350, 210, 80, 30) GUISetBkColor(0xA6CAF0) GUISetState() ; Load ListBox with the array contents _Update_ListBox() $Selectection = "" While 1 ; Poll the GUI Switch GUIGetMsg() ; Exit Case $GUI_EVENT_CLOSE MsgBox(0x40, 'please make sure browsers are turned off', $Checkboxonline ,10) Exit ; Select button pressed Case $hButton_Select $aSelected = _GUICtrlListBox_GetSelItems($hListBox) ; Write selected items to console For $i = 1 To $aSelected[0] ConsoleWrite("Item " & $aSelected[$i] & " selected" & @CRLF) ;msgbox (4096, "Test", $aSelected[$i], 10) $Selectection = $Selectection & $aSelected[$i] msgbox (4096, "Selection", $Selectection, 10) Next ConsoleWrite(@CRLF) ; Use the next case code to clear and reload the ListBox ContinueCase ; Clear button pressed Case $hButton_Clear ; Clear the items to remove selection status _GUICtrlListBox_ResetContent($hListBox) ; Reload ListBox _Update_ListBox() Case $hButton_OK msgbox (4096, "Final Selection ", $Selectection, 10) $Form2 = GUICreate("Run Defaults", 634, 448, 289, 213) GUISetBkColor(0xA6CAF0) $Group1 = GUICtrlCreateGroup("Global Default Details", 32, 8, 489, 57) GUICtrlSetFont(-1, 10, 400, 0, "Verdana") $Fullname = GUICtrlCreateLabel("Full Name", 48, 32, 60, 17) $Input1 = GUICtrlCreateInput($Display1, 112, 32, 121, 21) $oExcel2 = _ExcelBookOpen($sPathUSERS, 0) $aArrayUSER = _ExcelReadSheetToArray($oExcel2) Dim $sDetIdValue = '' For $i = 1 to 256 ;MsgBox(0x40, 'Read this DETID',_ExcelReadCell($oExcel2, $i, 1) & _ExcelReadCell($oExcel2, $i, 2)) ;MsgBox(0x40, 'This is Display1 ', $Display1 ) If _ExcelReadCell($oExcel2, $i, 1) = $Display1 Then ;MsgBox(0x40, 'This is what was read ', _ExcelReadCell($oExcel2, $i, 1) ) ;MsgBox(0x40, 'This is Display1 ', $Display1 ) $sDetIdValue = _ExcelReadCell($oExcel2, $i, 2) EndIf If _ExcelReadCell($oExcel2, $i, 1) = '' Then ;MsgBox(0x40, 'Cell count is ', $i) $cellcount = $i $i = 256 EndIf Next $cellcount = $cellcount - 1 _ExcelBookClose($oExcel2, 0) $hForm1 = GUICtrlGetHandle($Form1) ;GUIDelete(); $Label1 = GUICtrlCreateLabel("DET User Id", 248, 32, 73, 17) $Input2 = GUICtrlCreateInput($sDetIdValue, 344, 32, 121, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Course Offering Creation", 32, 80, 593, 113) GUICtrlSetFont(-1, 10, 400, 0, "Verdana") $Year = GUICtrlCreateLabel("Year", 40, 104, 30, 17) $Combo1 = GUICtrlCreateCombo("Year", 80, 104, 33, 25) $Semesterlabel = GUICtrlCreateLabel("Semester", 120, 104, 59, 17) $Semester = GUICtrlCreateCombo("Semester", 192, 104, 73, 25) $Label2 = GUICtrlCreateLabel("Course No", 272, 104, 64, 17) $Course = GUICtrlCreateCombo("Course No", 344, 104, 65, 25) $Label3 = GUICtrlCreateLabel("Location No", 40, 144, 70, 17) $Location = GUICtrlCreateCombo("Location No\", 120, 144, 89, 25) $Label4 = GUICtrlCreateLabel("Offer Type", 232, 144, 65, 17) $Combo2 = GUICtrlCreateCombo("Offer Type", 304, 144, 65, 25) $Label5 = GUICtrlCreateLabel("Offer Code", 392, 144, 67, 17) $Offer = GUICtrlCreateInput("Offer Code", 480, 144, 121, 21) GUISetState() $sFilePath = $sFilePathOrigin & $Display & '.xls' $oExcel = _ExcelBookOpen($sFilePath, 0, True) $vSheet = 'ScriptList' ; Move to correct sheet _ExcelSheetActivate($oExcel, $vSheet) GUICtrlCreateGroup("", -99, -99, 1, 1) ; Work down sheet until there is an empty cell While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $OK2 MsgBox(0x40, 'Pressed Ok2', "I can now process the input params?") Exit EndSwitch WEnd EndSwitch ; Set item to Selected when given focus by a mouse click - if not already done $iIndex = _GUICtrlListBox_GetCaretIndex($hListBox) If _GUICtrlListBox_GetSel($hListBox, $iIndex) = False Then _GUICtrlListBox_SetSel($hListBox, $iIndex) WEnd ;########################################################## Exit EndSwitch WEnd #EndRegion ### END Koda GUI section ### MsgBox(0x40, 'do I ever get here?', $Checkboxonline ,10) ;EndSwitch ;WEnd ; Create array - you would do this using the Excel UDFs Global $aArray[6] For $i = 1 to 5 $aArray[$i] = "Something from Excel " & $i - 1 Next $aArray[0] = 5 ; Create a GUI $hGUI = GUICreate("MultiSelect ListBox", 300, 250) $hListBox = _GUICtrlListBox_Create ($hGUI, "", 10, 10, 280, 180, $LBS_EXTENDEDSEL) $hButton_Select = GUICtrlCreateButton("Select", 30, 210, 80, 30) $hButton_Clear = GUICtrlCreateButton("Clear", 190, 210, 80, 30) GUISetState() ; Load ListBox with the array contents _Update_ListBox() $Selectection = "" While 1 ; Poll the GUI Switch GUIGetMsg() ; Exit Case $GUI_EVENT_CLOSE Exit ; Select button pressed Case $hButton_Select $aSelected = _GUICtrlListBox_GetSelItems($hListBox) ; Write selected items to console For $i = 1 To $aSelected[0] ConsoleWrite("Item " & $aSelected[$i] & " selected" & @CRLF) ;msgbox (4096, "Test", $aSelected[$i], 10) $Selectection = $Selectection & $aSelected[$i] msgbox (4096, "Selection", $Selectection, 10) Next ConsoleWrite(@CRLF) ; Use the next case code to clear and reload the ListBox ContinueCase ; Clear button pressed Case $hButton_Clear ; Clear the items to remove selection status _GUICtrlListBox_ResetContent($hListBox) ; Reload ListBox _Update_ListBox() EndSwitch ; Set item to Selected when given focus by a mouse click - if not already done $iIndex = _GUICtrlListBox_GetCaretIndex($hListBox) If _GUICtrlListBox_GetSel($hListBox, $iIndex) = False Then _GUICtrlListBox_SetSel($hListBox, $iIndex) WEnd Func _Update_ListBox() _GUICtrlListBox_BeginUpdate($hListBox) _GUICtrlListBox_ResetContent($hListBox) _GUICtrlListBox_InitStorage($hListBox, 100, 4096) ;_GUICtrlListBox_AddString ($hListBox, "") For $i = 1 To $aArray[0] _GUICtrlListBox_AddString ($hListBox, $aArray[$i]) Next _GUICtrlListBox_EndUpdate($hListBox) EndFunc