Country73 Posted June 16, 2008 Share Posted June 16, 2008 (edited) I've created a GUI that uses the GUICtrlCreateTab, GUICtrlCreateTabitem and GUICtrlCreateList. When launched three files are read to display, one for each tab that I've created. The files contain: Application Name;Path to installation Tab1 - Displays all of our Default installation packages Tab2 - Displays all of our "layered" installation packages (multiple installs looped together for a specific group) Tab3 - Displays a list of our Uninstall packages. (created to hack out remnants that are sometimes left behind after a regular uninstall) Everything was working fine, until I decided to be a little creative and split everything up by the three tabs. Now whenever the files are read in, the very top line is a 0. 'zero' **Is there a different way to display my readout so that the zero is not displayed? Not really sure why it is displayed in the first place. This is still a major "Work in Progress". FYI - This GUI ties into a much larger GUI expandcollapse popup#include <GuiConstants.au3> #include <Array.au3> #include <file.au3> $InstallGUI = GUICreate("Application Installs", 402, 634, 150, 150 );$WinPos[0] - 100, $WinPos[1] ) $DefInstallFile = "\\server\share\DefAppInstalls.txt" $LayInstallFile = "\\server\share\LayAppInstalls.txt" $UninstallFile = "\\server\share\AppRemove.txt" GUICtrlCreateLabel( "Please select the application to install and click OK", 20, 8, 364, 26 ) GUICtrlSetFont( -1, 11.5, 800 ) GUICtrlCreateLabel( "Most Applications require Administrative Credentials", 73, 38, 364, 26 ) GUICtrlCreatePic("\\server\share\Logo.bmp", 35, 530, 334, 68 ) $InsButton01 = GUICtrlCreateButton( "OK", 94, 481, 62, 24 ) $InsButton02 = GUICtrlCreateButton( "EXIT", 227, 481, 62, 24 ) $tab = GUICtrlCreateTab ( 87, 70, 210,394) $tab0 = GUICtrlCreateTabitem ("Default Applications") $DefaultMsg = GUICtrlCreateList( "", 90, 93, 203, 370 ) $tab1 = GuiCtrlCreateTabItem("Layers") $LayersMsg = GUICtrlCreateList("", 90, 93, 203, 370 ) $tab2 = GUICtrlCreateTabItem("Uninstall") $UninstallMsg = GUICtrlCreateList("", 90, 93, 203, 370 ) GUISetState(@SW_SHOW, $InstallGUI) inputFile( $DefInstallFile ) inputFile( $LayInstallFile ) inputFile( $UninstallFile ) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $InsButton02 Exit Case $msg = $InsButton01 If GUICtrlread ($tab) = 0 Then $msgDisplay = GUICtrlRead( $DefaultMsg, 0 ) ;installApp( $msgDisplay ) EndIf If GUICtrlread ($tab) = 1 Then $msgDisplay = GUICtrlRead( $LayersMsg, 0 ) ;installApp( $msgDisplay ) EndIf If GUICtrlread ($tab) = 2 Then $msgDisplay = guictrlread( $UninstallMsg, 0 ) ;installApp( $msgDisplay ) EndIf MsgBox( 0, "Selection", $msgDisplay ) EndSelect WEnd GUIDelete() Exit Func inputFile( $FileInput ) $IFileInstall = "" $IFilePath = "" $IFile = FileOpen( $FileInput, 0 ) IF $IFile = -1 THEN $IFileNames = "Unable to extract Applications for Install" MSGBOX( 4096, "ERROR", $IFileNames ) ENDIF While 1 $line = FileReadLine( $IFile ) IF @ERROR = -1 THEN EXITLOOP $aRecords = StringSplit( $line, ";" ) $IFileNames = $aRecords[1] & "|" & $IFileNames WEnd FileClose( $FileInput ) Select Case $FileInput = $DefInstallFile GUICtrlSetData( $DefaultMsg, $IFileNames ) Case $FileInput = $LayInstallFile GUICtrlSetData( $LayersMsg, $IFileNames ) Case $FileInput = $UninstallFile $msgDisplay = $UninstallMsg GUICtrlSetData( $UninstallMsg, $IFileNames ) EndSelect EndFunc FUNC installApp( $msgDisplay ) $file2 = FileOpen( $InstallFile, 0 ) IF $file2 = -1 THEN MSGBOX( 0, "ERROR", "Unable to pull paths" ) EXIT ENDIF While 1 $line2 = FileReadLine( $file2 ) IF @ERROR = -1 THEN EXITLOOP $bRecords = StringSplit( $line2, ";" ) IF $bRecords[1] = $msgDisplay THEN $InstallOpt = MSGBOX( 4, "INSTALL", "You chose to install: " & $bRecords[1] & @CRLF & "Choose YES to continue" ) IF $InstallOpt = 6 THEN GUICtrlSetState( $InsButton01, $GUI_DISABLE ) GUICtrlSetState( $InsButton02, $GUI_DISABLE ) ;RunWait(@COMSPEC & " /c " & $bRecords[2], "", @SW_MAXIMIZE ) MSGBOX( 0, "INSTALL", $bRecords[1] & @CRLF & $bRecords[2] ) GUICtrlSetState( $InsButton01, $GUI_ENABLE ) GUICtrlSetState( $InsButton02, $GUI_ENABLE ) ELSE MSGBOX( 0, "ABORT", "Installation aborted", 2 ) ENDIF EndIf WEnd EndFunc Any suggestions would be appreciated. Edited August 7, 2008 by Country73 If you try to fail and succeed which have you done?AutoIt Forum Search Link to comment Share on other sites More sharing options...
martin Posted June 16, 2008 Share Posted June 16, 2008 I've created a GUI that uses the GUICtrlCreateTab, GUICtrlCreateTabitem and GUICtrlCreateList. When launched three files are read to display, one for each tab that I've created. The files contain: Application Name;Path to installation Tab1 - Displays all of our Default installation packages Tab2 - Displays all of our "layered" installation packages (multiple installs looped together for a specific group) Tab3 - Displays a list of our Uninstall packages. (created to hack out remnants that are sometimes left behind after a regular uninstall) Everything was working fine, until I decided to be a little creative and split everything up by the three tabs. Now whenever the files are read in, the very top line is a 0. 'zero' **Is there a different way to display my readout so that the zero is not displayed? Not really sure why it is displayed in the first place. This is still a major "Work in Progress". FYI - This GUI ties into a much larger GUI expandcollapse popup#include <GuiConstants.au3> #include <Array.au3> #include <file.au3> $InstallGUI = GUICreate("Application Installs", 402, 634, 150, 150 );$WinPos[0] - 100, $WinPos[1] ) $DefInstallFile = "\\server\share\DefAppInstalls.txt" $LayInstallFile = "\\server\share\LayAppInstalls.txt" $UninstallFile = "\\server\share\AppRemove.txt" GUICtrlCreateLabel( "Please select the application to install and click OK", 20, 8, 364, 26 ) GUICtrlSetFont( -1, 11.5, 800 ) GUICtrlCreateLabel( "Most Applications require Administrative Credentials", 73, 38, 364, 26 ) GUICtrlCreatePic("\\server\share\Logo.bmp", 35, 530, 334, 68 ) $InsButton01 = GUICtrlCreateButton( "OK", 94, 481, 62, 24 ) $InsButton02 = GUICtrlCreateButton( "EXIT", 227, 481, 62, 24 ) $tab = GUICtrlCreateTab ( 87, 70, 210,394) $tab0 = GUICtrlCreateTabitem ("Default Applications") $DefaultMsg = GUICtrlCreateList( "", 90, 93, 203, 370 ) $tab1 = GuiCtrlCreateTabItem("Layers") $LayersMsg = GUICtrlCreateList("", 90, 93, 203, 370 ) $tab2 = GUICtrlCreateTabItem("Uninstall") $UninstallMsg = GUICtrlCreateList("", 90, 93, 203, 370 ) GUISetState(@SW_SHOW, $InstallGUI) inputFile( $DefInstallFile ) inputFile( $LayInstallFile ) inputFile( $UninstallFile ) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $InsButton02 Exit Case $msg = $InsButton01 If GUICtrlread ($tab) = 0 Then $msgDisplay = GUICtrlRead( $DefaultMsg, 0 ) ;installApp( $msgDisplay ) EndIf If GUICtrlread ($tab) = 1 Then $msgDisplay = GUICtrlRead( $LayersMsg, 0 ) ;installApp( $msgDisplay ) EndIf If GUICtrlread ($tab) = 2 Then $msgDisplay = guictrlread( $UninstallMsg, 0 ) ;installApp( $msgDisplay ) EndIf MsgBox( 0, "Selection", $msgDisplay ) EndSelect WEnd GUIDelete() Exit Func inputFile( $FileInput ) $IFileInstall = "" $IFilePath = "" $IFile = FileOpen( $FileInput, 0 ) IF $IFile = -1 THEN $IFileNames = "Unable to extract Applications for Install" MSGBOX( 4096, "ERROR", $IFileNames ) ENDIF While 1 $line = FileReadLine( $IFile ) IF @ERROR = -1 THEN EXITLOOP $aRecords = StringSplit( $line, ";" ) $IFileNames = $aRecords[1] & "|" & $IFileNames WEnd FileClose( $FileInput ) Select Case $FileInput = $DefInstallFile GUICtrlSetData( $DefaultMsg, $IFileNames ) Case $FileInput = $LayInstallFile GUICtrlSetData( $LayersMsg, $IFileNames ) Case $FileInput = $UninstallFile $msgDisplay = $UninstallMsg GUICtrlSetData( $UninstallMsg, $IFileNames ) EndSelect EndFunc FUNC installApp( $msgDisplay ) $file2 = FileOpen( $InstallFile, 0 ) IF $file2 = -1 THEN MSGBOX( 0, "ERROR", "Unable to pull paths" ) EXIT ENDIF While 1 $line2 = FileReadLine( $file2 ) IF @ERROR = -1 THEN EXITLOOP $bRecords = StringSplit( $line2, ";" ) IF $bRecords[1] = $msgDisplay THEN $InstallOpt = MSGBOX( 4, "INSTALL", "You chose to install: " & $bRecords[1] & @CRLF & "Choose YES to continue" ) IF $InstallOpt = 6 THEN GUICtrlSetState( $InsButton01, $GUI_DISABLE ) GUICtrlSetState( $InsButton02, $GUI_DISABLE ) ;RunWait(@COMSPEC & " /c " & $bRecords[2], "", @SW_MAXIMIZE ) MSGBOX( 0, "INSTALL", $bRecords[1] & @CRLF & $bRecords[2] ) GUICtrlSetState( $InsButton01, $GUI_ENABLE ) GUICtrlSetState( $InsButton02, $GUI_ENABLE ) ELSE MSGBOX( 0, "ABORT", "Installation aborted", 2 ) ENDIF EndIf WEnd EndFunc Any suggestions would be appreciated. Haven't studied you code to be able to understand your problem but I would expect you will get problems because you seem to have forgotten GUICtrlCreateTabItem("") ; end tabitem definition Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Country73 Posted June 18, 2008 Author Share Posted June 18, 2008 Oops! OK, put in the: GUICtrlCreateTabitem( "" ) Any other assistance on removing the zero from the list of items read in? Just testing out today, since I'm not at work, I changed the input files to local files on my machine. $DefInstallFile = "c:\DefAppInstalls.txt" $LayInstallFile = "c:\LayAppInstalls.txt" $UninstallFile = "c:\AppRemove.txt" Inside of all three files I just put the following info: Adobe 8.0;\\Server\Share\Adobe80.exe AdobeWriter;\\Server\Share\AdobeWriter.exe Once launched, the information is read in as: 0 Adobe 8.0 AdobeWriter I don't know why that leading zero is showing up. If you try to fail and succeed which have you done?AutoIt Forum Search Link to comment Share on other sites More sharing options...
martin Posted June 18, 2008 Share Posted June 18, 2008 Oops!OK, put in the: GUICtrlCreateTabitem( "" )Any other assistance on removing the zero from the list of items read in?Just testing out today, since I'm not at work, I changed the input files to local files on my machine.$DefInstallFile = "c:\DefAppInstalls.txt"$LayInstallFile = "c:\LayAppInstalls.txt"$UninstallFile = "c:\AppRemove.txt"Inside of all three files I just put the following info:Adobe 8.0;\\Server\Share\Adobe80.exeAdobeWriter;\\Server\Share\AdobeWriter.exeOnce launched, the information is read in as:0Adobe 8.0AdobeWriterI don't know why that leading zero is showing up.You need to post code that will at least run. What is $InstallFile? (in the installApp function) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Country73 Posted June 20, 2008 Author Share Posted June 20, 2008 Actually got the zero line taken care of. I finally updated AutoIT to v3.2.12.1 and that cleared the problem. The $InstallFile should have actually been $msgDisplay. Too much updating one portion of script, and not throughout. Sorry for wasting any of your time on this. If you try to fail and succeed which have you done?AutoIt Forum Search Link to comment Share on other sites More sharing options...
Country73 Posted June 20, 2008 Author Share Posted June 20, 2008 Guess I could have posted the finalized script, at least this portion, for those interested. This is a fairly large script that I'm working on, so I've posted the portion that has to do with the initial question I had. Creation of the InstallationGUI #region ;Installation GUI - Start $InstallGUI = GUICreate("Application Installs", 402, 634, $WinPos[0] - 100, $WinPos[1] ) GUICtrlCreateLabel( "Please select the application to install and click OK", 20, 8, 364, 26 ) GUICtrlSetFont( -1, 11.5, 800 ) GUICtrlCreateLabel( "Most Applications require Administrative Credentials", 73, 38, 364, 26 ) GUICtrlCreatePic("\\Server\share\myLogo.bmp", 35, 530, 334, 68 ) $InsButton01 = GUICtrlCreateButton( "OK", 94, 481, 62, 24 ) $InsButton02 = GUICtrlCreateButton( "EXIT", 227, 481, 62, 24 ) #endregion #region ;Installation GUI - Tab creation $tab = GUICtrlCreateTab ( 87, 70, 210,394) $tab0 = GUICtrlCreateTabitem ("Default Applications") $DefaultMsg = GUICtrlCreateList( "", 90, 93, 203, 370 ) $tab1 = GuiCtrlCreateTabItem("Layers") $LayersMsg = GUICtrlCreateList("", 90, 93, 203, 370 ) $tab2 = GUICtrlCreateTabItem("Uninstall") $UninstallMsg = GUICtrlCreateList("", 90, 93, 203, 370 ) GUISetState(@SW_HIDE,$InstallGUI) #endregion #region ;Installation GUI - Read each input file - END of Installation GUI inputFile( $DefInstallFile );Read in the Default Applications list inputFile( $LayInstallFile );Read in the Layers Application list inputFile( $UninstallFile ) ;Read in the Uninstall Application list #endregion This portion is in a larger While / WEnd for handling any InstallationGUI selections: ;Installation GUI Case $msg = $InsButton01 If GUICtrlread ($tab) = 0 Then ;DefaultApps tab visible $AppList = GUICtrlRead( $DefaultMsg, 0 ) ;Read from DefaultApps Tab installApp( $AppList,$DefInstallFile ) ;Call the installation function EndIf If GUICtrlread ($tab) = 1 Then ;Layers tab visible $AppList = GUICtrlRead( $LayersMsg, 0 ) ;Read from Layers Tab InstallApp( $AppList,$LayInstallFile ) ;Call the installation function EndIf If GUICtrlread ($tab) = 2 Then ;Uninstall tab visible $AppList = GUICtrlRead( $UninstallMsg, 0 ) ;Read from Uninstall Tab InstallApp( $AppList,$UninstallFile ) ;Call the installation function (uninstall) EndIf Case $msg = $InsButton02 ;Close Install GUI GUISetState(@SW_HIDE, $InstallGUI) Here is the Function that reads in the files as soon as the GUI is launched: Func inputFile( $FileInput ) ;Installation GUI, Read in Files $IFilePath = "" $IFileNames = "" $IFile = FileOpen( $FileInput, 0 ) IF $IFile = -1 THEN $IFileNames = "Unable to extract Applications for Install" MSGBOX( 4096, "ERROR", $IFileNames ) ENDIF While 1 $line = FileReadLine( $IFile ) IF @ERROR = -1 THEN EXITLOOP $aRecords = StringSplit( $line, ";" ) $IFileNames = $aRecords[1] & "|" & $IFileNames $IFilePath = $aRecords[2] & "|" & $IFilePath WEnd FileClose( $FileInput ) Select Case $FileInput = $DefInstallFile GUICtrlSetData( $DefaultMsg, $IFileNames ) Case $FileInput = $LayInstallFile GUICtrlSetData( $LayersMsg, $IFileNames ) Case $FileInput = $UninstallFile $msgDisplay = $UninstallMsg GUICtrlSetData( $UninstallMsg, $IFileNames ) EndSelect EndFunc Finally the Installation portion of the GUI: FUNC installApp( $msgApp,$msgDisplay ) ;Installation GUI, Run installations $file2 = FileOpen( $msgDisplay, 0 ) IF $file2 = -1 THEN MSGBOX( 0, "ERROR", "Unable to pull paths" ) EXIT ENDIF While 1 $line2 = FileReadLine( $file2 ) IF @ERROR = -1 THEN EXITLOOP $bRecords = StringSplit( $line2, ";" ) IF $msgApp = "0" THEN MSGBOX( 0, "ERROR", "Please make another selection." & @CRLF & "This selection will be removed in a future update", 4 ) ExitLoop ELSEIF $bRecords[1] = $msgApp THEN $InstallOpt = MSGBOX( 4, "INSTALL", "You chose to install: " & $bRecords[1] & @CRLF & "Choose YES to continue" ) IF $InstallOpt = 6 THEN GUICtrlSetState( $InsButton01, $GUI_DISABLE ) GUICtrlSetState( $InsButton02, $GUI_DISABLE ) MSGBOX( 0, "INSTALL", $bRecords[1] & @CRLF & $bRecords[2] ) GUICtrlSetState( $InsButton01, $GUI_ENABLE ) GUICtrlSetState( $InsButton02, $GUI_ENABLE ) ELSE MSGBOX( 0, "ABORT", "Installation aborted", 2 ) ENDIF EndIf WEnd EndFunc All three of the input files will have the display name for the application then a semicolon and the actual path to the application. Example Adobe 8.0;\\server\share\adobe\Adobe80.exe Any pointers on better scripting would be appreciated. Thanks, If you try to fail and succeed which have you done?AutoIt Forum Search 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