Sign in to follow this  
Followers 0
Country73

Gui Assistance

3 posts in this topic

I'm curious if I'm going the right route, or if there's a better way to handle this.

***Novice with AutoIt

This GUI populates the list by reading from a text file.

I want the user to be able to type in the Input, or select from the list, so that when they click on "OK" it will install the application.

At the very beginning here, so all of that is not in place yet.

Mainly curious if there is a better way to handle it then what I've put together.

Thanks in advance,

#include <GuiConstants.au3>
#include <Array.au3>
#include <file.au3>

$InstallFile = "c:\Apps\AppInstalls.txt"

$InstallGUI = GUICreate("Application Installs", 402, 610, 150, 150 )
GuiCtrlCreatePic("c:\Pics\ssLogo2.bmp", 30, 529, 335, 69)
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, 28, 364, 26 )
$InstallInput = GUICtrlCreateInput("", 88, 50, 209, 20 )

DIM $aRecords
IF NOT _FileReadToArray( $InstallFile, $aRecords ) THEN
    $IFileOutput = "Unable to extract Application Installations"
    $IFileInstall = "Unable to extract Application Installation Paths"
    $IFileGather = FALSE
ENDIF
FOR $X = 1 TO $aRecords[0]
    $A = StringSplit( $aRecords[$x], ";" )
    $IFileOutput = $IFileOutput & "|" & $A[1]
    $IFileInstall = $IFileInstall & "|" & $A[2]
NEXT
GuiCtrlCreateList( "", 87, 70, 210, 394 )
GuiCtrlSetData( -1, $IFileOutput )
$ButtonI1 = GUICtrlCreateButton( "OK", 94, 481, 62, 24 )
$ButtonI2 = GUICtrlCreateButton( "EXIT", 227, 481, 62, 24 )
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $ButtonI2
            Exit
        Case $msg = $ButtonI1
            MSGBOX( 0, "Installation Information", $IFileOutput )
    EndSelect
WEnd
;========================================================================================
;   Closing out of Helpdesk Central
;========================================================================================
GUIDelete()
Exit

If you try to fail and succeed which have you done?AutoIt Forum Search

Share this post


Link to post
Share on other sites



I was on the phone for a while... anyways,

#include <GuiConstants.au3>
#include <Array.au3>
#include <file.au3>

$InstallFile = "c:\Apps\AppInstalls.txt"

$InstallGUI = GUICreate("Application Installs", 402, 610);, 150, 150)
GUICtrlCreatePic("c:\Pics\ssLogo2.bmp", 30, 529, 335, 69)
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, 28, 364, 26)
;$InstallInput = GUICtrlCreateInput("", 88, 50, 209, 20); this is tuffer, maybe use for install arguments???

Dim $aRecords
If Not _FileReadToArray($InstallFile, $aRecords) Then
    $IFileOutput = "Unable to extract Application Installations"
    $IFileInstall = "Unable to extract Application Installation Paths"
    $IFileGather = False
Else
    For $X = 1 To $aRecords[0]
        $A = StringSplit($aRecords[$X], ";")
        $IFileOutput = $IFileOutput & "|" & $A[1]
        $IFileInstall = $IFileInstall & "|" & $A[2]
    Next
EndIf

; ; this is for example only
$aRecords = StringSplit("This_program;c:\program files\This_program.exe,That_program;c:\program files\That_program.exe,Which_program;c:\program files\Which_program.exe", ",") ; this is for example only
    For $X = 1 To $aRecords[0]
        $A = StringSplit($aRecords[$X], ";")
        $IFileOutput = $IFileOutput & "|" & $A[1]
        $IFileInstall = $IFileInstall & "|" & $A[2]
    Next
; end example area
$List = GUICtrlCreateList("", 87, 70, 210, 394)
GUICtrlSetData(-1, $IFileOutput)
$ButtonI1 = GUICtrlCreateButton("OK", 94, 481, 62, 24)
$ButtonI2 = GUICtrlCreateButton("EXIT", 227, 481, 62, 24)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $ButtonI2
            Exit
        Case $msg = $ButtonI1
            $info = GUICtrlRead($List)
            If $info <> "" and $info <> "Unable to extract Application Installations" Then 
            MsgBox(0, "Installation Information", "You have chosen " & $info & "  ", 3)
            Start_Install($info)
            EndIf            
    EndSelect
WEnd
;========================================================================================
;    Closing out of Helpdesk Central
;========================================================================================
GUIDelete()
Exit



Func Start_Install($program)
    For $X = 1 To $aRecords[0]
        $A = StringSplit($aRecords[$X], ";")
        If StringInStr($A[1], $info) Then
            MsgBox(0x0,"Installing...", $A[2])
            ; Do something ?
            Return
        EndIf
    Next
    MsgBox(0x0,"Sorry!", "The program was not found   ")
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I'll take a look at it shortly.

Moving to a new building/floor, here at work, so it will probably be later this afternoon.

Thanks for taking a look at it.


If you try to fail and succeed which have you done?AutoIt Forum Search

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0