Jump to content

combobox question


 Share

Recommended Posts

Hi All! I am trying (or wanting) to build a GUI that will allow me to 1st pick the operating system from a combobox then go to the OS I choose GUI to pick what software I want to install and then execute the scripts I've already made.

I'm using a script Installer Thing to start out with but I can't figure out how to get my combobox to select the OS choice from the combobox to go to the GUI for that OS so I can pick what software I want to install. I've called myself looking in the help file and read on some forums about GuiComboBox Management section, which I can't seem to find. Can someone help point the way for what I'm trying to do?

Here's what I got so far (very incomplete, just a starting point)

#Region ;YOU HAVE TO CHANGE THIS TO YOUR FILES _________________ SAMPLE INFO
#AutoIt3Wrapper_Res_File_Add=file.exe
#AutoIt3Wrapper_Res_File_Add=file1.exe
#EndRegion ;CHANGE TO YOUR FILES

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
Opt("GUIoneventmode", 1)
global $change_dir

$name = "Software Installation Wizard";name of your product
$name1 = "Windows 2000 Pro Software Installation Wizard"
$name2 = "Windows XP Home Software Installation Wizard"
$warning = "Are you sure you want to continue?" & @CRLF & " Yes" & @CRLF & " No"

GUICreate($name, 300, 140)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Please Select your Operating System.", 26, 8, 300, 17)
$combo1 = GUICtrlCreateCombo("Please Select", 32, 40, 177, 25)
GUICtrlSetData(-1, "2000 Professional|XP Home|XP Professional|XP MCE 2002|XP MCE 2005|Vista Home Basic|Vista Home Premium|Vista Business|Vista Ultimate")
GUICtrlCreateButton("Next", 16, 80, 97, 25, 0)
GUICtrlSetOnEvent(-1,"_w2k")
GUICtrlCreateButton("Cancel", 120, 80, 97, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUISetState(@SW_SHOW)

; Exit the program
Func _Exit()
$Exit = MsgBox(262452,"Exit","Are You Sure You Want To Exit?")
If $Exit = 6 Then
Exit
Endif
EndFunc

; Next - Continue
Func _Next()
$change_dir = FileSelectFolder("Where Would You Like To Install?", "", 1+2+4, "c\:")
if $warning = "" then
_warning()
EndIf
EndFunc

; Warning Message
Func _warning()
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 497, 359)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateButton("Cancel", 408, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
GUICtrlCreateButton("Continue", 320, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateEdit($warning, 0, 64, 489, 249)
GUICtrlCreateLabel("0", 0, -8, 494, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("Are you sure you want to continue? ", 40, 28, 288, 17)
GUIctrlSetFont(8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
Endfunc

; Windows 2000 Pro
Func _w2k()
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the " &$name1, 50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Home
Func _wxph()
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the " &$name2, 50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc


; This is all Sample Info ------------------------------------ Below This Line

Func _install()
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 391, 136)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Installing Autoit", 8, 8, 109, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please wait as we install needed components to your computer.", 48, 32, 303, 17)
GUICtrlCreateButton("Cancel", 160, 96, 75, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
$Progress1 = GUICtrlCreateProgress(16, 56, 361, 25)
GUISetState(@SW_SHOW)

DirCreate($change_dir & $name)
FileInstall("File.exe",$change_dir & $name & "/file.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File1.exe",$change_dir & $name & "/file1.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File9.exe",$change_dir & $name & "/file9.exe")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
Msgbox(0,"Complete",$name & " Has been installed to your Computer")
Exit
EndFunc

While 1
sleep(10)
WEnd

Thanks in advance for any help you can provide me!

Edited by pcjames
Link to comment
Share on other sites

Hi All! I am trying (or wanting) to build a GUI that will allow me to 1st pick the operating system from a combobox then go to the OS I choose GUI to pick what software I want to install and then execute the scripts I've already made.

I'm using a script Installer Thing to start out with but I can't figure out how to get my combobox to select the OS choice from the combobox to go to the GUI for that OS so I can pick what software I want to install. I've called myself looking in the help file and read on some forums about GuiComboBox Management section, which I can't seem to find. Can someone help point the way for what I'm trying to do?

Here's what I got so far (very incomplete, just a starting point)

#Region ;YOU HAVE TO CHANGE THIS TO YOUR FILES _________________ SAMPLE INFO
#AutoIt3Wrapper_Res_File_Add=file.exe
#AutoIt3Wrapper_Res_File_Add=file1.exe
#EndRegion ;CHANGE TO YOUR FILES

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
Opt("GUIoneventmode", 1)
global $change_dir

$name = "Software Installation Wizard";name of your product
$name1 = "Windows 2000 Pro Software Installation Wizard"
$name2 = "Windows XP Home Software Installation Wizard"
$warning = "Are you sure you want to continue?" & @CRLF & " Yes" & @CRLF & " No"

GUICreate($name, 300, 140)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Please Select your Operating System.", 26, 8, 300, 17)
$combo1 = GUICtrlCreateCombo("Please Select", 32, 40, 177, 25)
GUICtrlSetData(-1, "2000 Professional|XP Home|XP Professional|XP MCE 2002|XP MCE 2005|Vista Home Basic|Vista Home Premium|Vista Business|Vista Ultimate")
GUICtrlCreateButton("Next", 16, 80, 97, 25, 0)
GUICtrlSetOnEvent(-1,"_w2k")
GUICtrlCreateButton("Cancel", 120, 80, 97, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUISetState(@SW_SHOW)

; Exit the program
Func _Exit()
$Exit = MsgBox(262452,"Exit","Are You Sure You Want To Exit?")
If $Exit = 6 Then
Exit
Endif
EndFunc

; Next - Continue
Func _Next()
$change_dir = FileSelectFolder("Where Would You Like To Install?", "", 1+2+4, "c\:")
if $warning = "" then
_warning()
EndIf
EndFunc

; Warning Message
Func _warning()
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 497, 359)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateButton("Cancel", 408, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
GUICtrlCreateButton("Continue", 320, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateEdit($warning, 0, 64, 489, 249)
GUICtrlCreateLabel("0", 0, -8, 494, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("Are you sure you want to continue? ", 40, 28, 288, 17)
GUIctrlSetFont(8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
Endfunc

; Windows 2000 Pro
Func _w2k()
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the " &$name1, 50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Home
Func _wxph()
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the " &$name2, 50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc


; This is all Sample Info ------------------------------------ Below This Line

Func _install()
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 391, 136)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Installing Autoit", 8, 8, 109, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please wait as we install needed components to your computer.", 48, 32, 303, 17)
GUICtrlCreateButton("Cancel", 160, 96, 75, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
$Progress1 = GUICtrlCreateProgress(16, 56, 361, 25)
GUISetState(@SW_SHOW)

DirCreate($change_dir & $name)
FileInstall("File.exe",$change_dir & $name & "/file.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File1.exe",$change_dir & $name & "/file1.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File9.exe",$change_dir & $name & "/file9.exe")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
Msgbox(0,"Complete",$name & " Has been installed to your Computer")
Exit
EndFunc

While 1
sleep(10)
WEnd

Thanks in advance for any help you can provide me!

You need to register an event handler for the combo.

GUICtrlSetOnEvent(-1,"beginwork")
Func beginwork()
 $selectedOS = GuiCtrlRead($combo1)
Select
 $selectedOS = "2000 Professional"
      _wxph()
 $selectedOS = ....

 EndSelect
endfunc

EDIT:corrected code tags

Edited by martin
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

Hey martin, I've worked with this all day, changed the code a little after reading the help file searching the forums looking at other code. When I run the Syntax check I'm getting 1. Syntax error with $selectedOS , 2. GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit") and GUICtrlSetOnEvent(-1, "CancelPressed") saying it's an "Undefined Function" which I thought I defined and 3. when I run the script I get "Select" statement is missing "EndSelect" or "Case" statement.:Select I'm trying hard to understand this but so far I'm just not getting it.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
Opt("GUIoneventmode", 1)
Opt('MustDeclareVars', 1)
global $name, $name1, $name2, $warning, $Exit, $cancel


$name = "Software Installation Wizard"
$name1 = "Windows 2000 Professional"
$name2 = "Windows XP Home"
$warning = "Are you sure you want to continue?" & @CRLF & " Yes" & @CRLF & " No"


GUICreate($name, 300, 140)
  Local $combo1
  GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
  GUICtrlCreateLabel("Please Select your Operating System.", 26, 8, 300, 17)
  $combo1 = GUICtrlCreateCombo("Please Select", 32, 40, 177, 25)
  GUICtrlSetData(-1, "Windows 2000 Professional|Windows XP Home")
  GUICtrlCreateButton("Next", 16, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1,"getos")
  $cancel = GUICtrlCreateButton("Cancel", 120, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1, "CancelPressed")
  GUISetState(@SW_SHOW)


Func getos()
    Local $selectedOS
$selectedOS = GuiCtrlRead($combo1)
Select  
$selectedOS = "Windows 2000 Professional"
_wxph()
$selectedOS = "Windows XP Home"

EndSelect
endfunc

; Exit the program
Func _Exit()
    $Exit = MsgBox(262452,"Exit","Are You Sure You Want To Exit?")
    If $Exit = 6 Then
    Exit
    Endif
EndFunc
; Cancel then Exit the program
Func CancelPressed()
    $cancel = MsgBox(262452,"Cancel","Are You Sure You Want To Cancel?")
    If $cancel = 6 Then
    Exit
    Endif
EndFunc

; Windows 2000 Pro
Func _w2k()
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the " &$name1, &$name, 50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Home
Func _wxph()
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the " &$name2, &$name,  50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc

; This is all Sample Info ------------------------------------ Below This Line

Func _install()
    Local $change_dir,
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 391, 136)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Installing Autoit", 8, 8, 109, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please wait as we install needed components to your computer.", 48, 32, 303, 17)
GUICtrlCreateButton("Cancel", 160, 96, 75, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
$Progress1 = GUICtrlCreateProgress(16, 56, 361, 25)
GUISetState(@SW_SHOW)

DirCreate($change_dir & $name)
FileInstall("File.exe",$change_dir & $name & "/file.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File1.exe",$change_dir & $name & "/file1.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File9.exe",$change_dir & $name & "/file9.exe")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
Msgbox(0,"Complete",$name & " Has been installed to your Computer")
Exit
EndFunc

While 1
sleep(10)
WEnd
Edited by pcjames
Link to comment
Share on other sites

Thanks BugFix for pointing me towards another piece of the puzzle!

Well the positive part is I don't have any syntax errors :D but as you can see from the msg in the script "It doesn't choose any of my choices, but when I hit next it's trying to go to my _w2k GUI, it's trying to open and the GUI won't stay open without this msg"

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
Opt("GUIoneventmode", 1)
Opt('MustDeclareVars', 1)
global $name, $name1, $name2, $warning, $Exit, $cancel


$name = "Software Installation Wizard"
$name1 = "Windows 2000 Professional"
$name2 = "Windows XP Home"
$warning = "Are you sure you want to continue?" & @CRLF & " Yes" & @CRLF & " No"


GUICreate($name, 300, 140)
  Local $combo1, $Cancel
  GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
  GUICtrlCreateLabel("Please Select your Operating System.", 26, 8, 300, 17)
  $combo1 = GUICtrlCreateCombo("Please Select", 32, 40, 177, 25)
  GUICtrlSetData(-1, "Windows 2000 Professional|Windows XP Home")
  GUICtrlCreateButton("Next", 16, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1,"getos")
  $cancel = GUICtrlCreateButton("Cancel", 120, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1, "CancelPressed")
  GUISetState(@SW_SHOW)

Func getos()
  Local $combo1
    Select  
      
      Case GuiCtrlRead($combo1) = "Windows 2000 Professional"
        _w2k()
        MsgBox(0, "", "It doesn't choose any of my choices, but when I hit next it's trying to go to my _w2k GUI, it's trying to open and the GUI won't stay open without this msg")
        Exit
      
      Case GuiCtrlRead($combo1) = "Windows XP Home"
        _wxph()
        MsgBox(0, "", "I have choosen Windows XP Home but it opens my _wxph")
        Exit        
        
    EndSelect
endfunc

; Exit the program
Func _Exit()
  Local $Exit    
    $Exit = MsgBox(262452,"Exit","Are You Sure You Want To Exit?")
    If $Exit = 6 Then
    Exit
    Endif
EndFunc
; Cancel then Exit the program
Func CancelPressed()
  Local $Cancel 
    $Cancel = MsgBox(262452,"Cancel","Are you sure you want to Cancel and then Exit?")
    If $Cancel = 6 Then
    Exit
    Endif
EndFunc

; Windows 2000 Pro
Func _w2k()
  Local $name, $name1, $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the ", $name1, $name, 50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Home
Func _wxph()
  Local $name, $name2, $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the ", $name2, $name,  50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 3", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc

; This is all Sample Info ------------------------------------ Below This Line

Func _install()
    Local $change_dir, $Progress1, $name
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 391, 136)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Installing Autoit", 8, 8, 109, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please wait as we install needed components to your computer.", 48, 32, 303, 17)
GUICtrlCreateButton("Cancel", 160, 96, 75, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
$Progress1 = GUICtrlCreateProgress(16, 56, 361, 25)
GUISetState(@SW_SHOW)

DirCreate($change_dir & $name)
FileInstall("File.exe",$change_dir & $name & "/file.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File1.exe",$change_dir & $name & "/file1.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File9.exe",$change_dir & $name & "/file9.exe")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
Msgbox(0,"Complete",$name & " Has been installed to your Computer")
Exit
EndFunc

While 1
sleep(10)
WEndoÝ÷ Ùg¥Úòx-¡·v÷§¶êèºÆ§uÖ«xÆ«g§¶)àÂ+a²r^rìÈz0"wvÚwZÁ¬­¢Ç¥yËmç!¢'"wuúèØ^r¡º1²azrjzZ²É²r"qëh+ç-yÓ~éܶ*'"ÚâyÛayÊy·¥£DÒ
Ú'ßÛm¯+h{º×+7Üay"¶¬jZ(¦ènW¦rìèf§ßyfj­ßÛ!j·m¢H¥ºÚ"µÍ[ÈÙ]ÜÊ
BØØ[  ÌÍÙÙ]ÔË   ÌÍØÛÛXÌK  ÌÍÓ^ ÌÍÑÕRWÑUSÐÓÔÑBÚ[HBH   ÌÍÙÙ]ÔÈHÝZPÝXY
    ÌÍØÛÛXÌJBÙ[XÝHØÙH ÌÍÙÙ]ÔÈH  ÌÍÓ^BHÙ[XÝBBHØÙHÝZPÝXY
    ÌÍØÛÛXÌJHH    ][ÝÕÚ[ÝÜÈÙÜÚ[Û[   ][ÝÂÝÌÊ
BBBHØÙHÝZPÝXY
    ÌÍØÛÛXÌJHH    ][ÝÕÚ[ÝÜÈÛYI][ÝÂÝÞ

B[Ù[XÝØÙH   ÌÍÙÙ]ÔÈH  ÌÍÑÕRWÑUSÐÓÔÑBBH^][Ù[XÝÑ[[[

Anyways I got to go fix some computers to pay the bills, can't spend all my time trying to learn autoit. Hopefully someone can direct me to another piece of the puzzle, if not I'll bang my head :D some more when I get back!

Thanks All!

Link to comment
Share on other sites

All that messagebox is doing is pausing your script. You can pause your script with a do loop and use and _ispressed to get out if you like. Perhaps this tweak will set you off on the right direction.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include<Misc.au3>
Opt("GUIoneventmode", 1)
Opt('MustDeclareVars', 1)
global $name, $name1, $name2, $warning, $Exit, $cancel


$name = "Software Installation Wizard"
$name1 = "Windows 2000 Professional"
$name2 = "Windows XP Home"
$warning = "Are you sure you want to continue?" & @CRLF & " Yes" & @CRLF & " No"


GUICreate($name, 300, 140)
  Local $combo1, $Cancel
  GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
  GUICtrlCreateLabel("Please Select your Operating System.", 26, 8, 300, 17)
  $combo1 = GUICtrlCreateCombo("Please Select", 32, 40, 177, 25)
  GUICtrlSetData(-1, "Windows 2000 Professional|Windows XP Home")
  GUICtrlCreateButton("Next", 16, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1,"getos")
  $cancel = GUICtrlCreateButton("Cancel", 120, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1, "CancelPressed")
  GUISetState(@SW_SHOW)

Func getos()
  Local $combo1
    Select  
      
      Case GuiCtrlRead($combo1) = "Windows 2000 Professional"
        _w2k()
      ; MsgBox(0, "", "It doesn't choose any of my choices, but when I hit next it's trying to go to my _w2k GUI, it's trying to open and the GUI won't stay open without this msg")
        Exit
      
      Case GuiCtrlRead($combo1) = "Windows XP Home"
        _wxph()
        MsgBox(0, "", "I have choosen Windows XP Home but it opens my _wxph")
        Exit        
        
    EndSelect
endfunc

; Exit the program
Func _Exit()
  Local $Exit   
    $Exit = MsgBox(262452,"Exit","Are You Sure You Want To Exit?")
    If $Exit = 6 Then
    Exit
    Endif
EndFunc
; Cancel then Exit the program
Func CancelPressed()
  Local $Cancel 
    $Cancel = MsgBox(262452,"Cancel","Are you sure you want to Cancel and then Exit?")
    If $Cancel = 6 Then
    Exit
    Endif
EndFunc

; Windows 2000 Pro
Func _w2k()
  Local $name, $name1, $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the ", $name1, $name, 50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
Do
    sleep(30)
until _IsPressed("0D","user32.dll")
EndFunc

; Windows XP Home
Func _wxph()
  Local $name, $name2, $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name, 675, 300)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Welcome to the ", $name2, $name,  50, 8, 600, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$check1 = GUICtrlCreateCheckbox ("Service Pack 3", 30, 90, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 120, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 150, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 180, 160, 30)
GUICtrlCreateLabel("Click Next to continue",50, 264, 108, 17)
GUICtrlCreateButton("Cancel", 312, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_exit")
GUICtrlCreateButton("Next", 224, 320, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUISetState(@SW_SHOW)
EndFunc

; This is all Sample Info ------------------------------------ Below This Line

Func _install()
    Local $change_dir, $Progress1, $name
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 391, 136)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUICtrlCreateLabel("Installing Autoit", 8, 8, 109, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please wait as we install needed components to your computer.", 48, 32, 303, 17)
GUICtrlCreateButton("Cancel", 160, 96, 75, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
$Progress1 = GUICtrlCreateProgress(16, 56, 361, 25)
GUISetState(@SW_SHOW)

DirCreate($change_dir & $name)
FileInstall("File.exe",$change_dir & $name & "/file.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File1.exe",$change_dir & $name & "/file1.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File9.exe",$change_dir & $name & "/file9.exe")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
Msgbox(0,"Complete",$name & " Has been installed to your Computer")
Exit
EndFunc

While 1
sleep(10)
WEnd
Link to comment
Share on other sites

@ picea892 you may be right about the msg box but I just threw the msg's in there as to see if the function was working right, which it isn't. No matter what I select from the combobox the function passes it to the _w2k, As a matter of fact... I don't even have to select anything just click on the next button and it goes to the _w2k function. Thanks for you suggestion anyways!

Anyways here's my latest attempt, No Errors, goes to the _w2k function and actually tries to install :D but I still haven't figured out how to select my choices from the comobox. I'm sure my getos and then the "next" button are my issues, Will keep trying!

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
Opt("GUIoneventmode", 1)
Opt('MustDeclareVars', 1)
global $name = "Software Installation Wizard", $Exit, $cancel

GUICreate($name, 300, 140)
  Local $combo1, $cancel, $getos
  GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
  GUICtrlCreateLabel("Please Select your Operating System.", 26, 8, 300, 17)
  $combo1 = GUICtrlCreateCombo("Please Select", 32, 40, 177, 25)
  GUICtrlSetData(-1, "Windows 2000 Professional|Windows XP Home", "")
  $getos = GUICtrlCreateButton("Next", 16, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1,"getos")
  $cancel = GUICtrlCreateButton("Cancel", 120, 80, 97, 25, 0)
  GUICtrlSetOnEvent(-1, "CancelPressed")
  GUISetState(@SW_SHOW)

Func getos()
 Local $combo1, $OS = GUICtrlRead($combo1)
   Select 
     Case $OS = "Windows 2000 Professional"
       _w2k()
     Case $OS = "Windows XP Home"
       _wxph()
   EndSelect
EndFunc

EDIT: I forgot that I changed some code before the getos function

Edited by pcjames
Link to comment
Share on other sites

It Works! It Works! Well at least the combobox works! I was cleaning up some of the code and kept trying the script and it worked! Thanks martin & bugfix for your hints, I guess I was trying to make it harder than it actually was.

Anyways here's the working code - so far - but still a work in progress

#include <GuiConstantsEx.au3>

Opt("GUIoneventmode", 1)
Opt('MustDeclareVars', 1)

global $name = "Software Installation Wizard", $cancel

GUICreate($name, 300, 140)
Local $combo1
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Please Select your Operating System.", 26, 8, 300, 17)
$combo1 = GUICtrlCreateCombo("Please Select", 32, 40, 177, 25)
GUICtrlSetData(-1, "Windows 2000 Professional|Windows XP Home")
GUICtrlCreateButton("Next", 16, 80, 97, 25, 0)
GUICtrlSetOnEvent(-1,"getos")
$cancel = GUICtrlCreateButton("Cancel", 120, 80, 97, 25, 0)
GUICtrlSetOnEvent(-1, "CancelPressed")
GUISetState(@SW_SHOW)

; Select the OS
Func getos()
 Local $OS = GUICtrlRead($combo1)
   Select 
     Case $OS = "Windows 2000 Professional"
       _w2k()
     Case $OS = "Windows XP Home"
       _wxph()
   EndSelect
EndFunc

; Exit the program
Func _Exit()
  Local $Exit    
    $Exit = MsgBox(262452,"Exit","Are You Sure You Want To Exit?")
    If $Exit = 6 Then
    Exit
    Endif
EndFunc

; Cancel then Exit the program
Func CancelPressed()
  Local $Cancel 
    $Cancel = MsgBox(262452,"Cancel","Are you sure you want to Cancel and then Exit?")
    If $Cancel = 6 Then
    Exit
    Endif
EndFunc

; Windows 2000 Pro
Func _w2k()
  Local $name1 = "Windows 2000 Professional ", $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name, 675, 350)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Welcome to the " & $name1 & $name, 30, 8, 645, 24)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please select the software you want to install", 30, 40, 645, 24)
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 65, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 90, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 115, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 140, 160, 30)
GUICtrlCreateButton("Back", 414, 310, 73, 25, 0)
GUICtrlCreateButton("Next", 497, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateButton("Cancel", 580, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Home
Func _wxph()
  Local $name2 = "Windows XP Home ", $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name, 675, 350)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Welcome to the " & $name2 & $name, 30, 8, 600, 24)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please select the software you want to install", 30, 40, 645, 24)
$check1 = GUICtrlCreateCheckbox ("Service Pack 3", 30, 65, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 90, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 115, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 140, 160, 30)
GUICtrlCreateButton("Back", 414, 310, 73, 25, 0)
GUICtrlCreateButton("Next", 497, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateButton("Cancel", 580, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState(@SW_SHOW)
EndFunc

; This is all Sample Info ------------------------------------ Below This Line

Func _install()
    Local $change_dir, $Progress1, $name
GUISetState(@SW_Hide)
GUICreate($name & " Setup", 391, 136)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Installing Autoit", 8, 8, 109, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please wait as we install needed components to your computer.", 48, 32, 303, 17)
GUICtrlCreateButton("Cancel", 160, 96, 75, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
$Progress1 = GUICtrlCreateProgress(16, 56, 361, 25)
GUISetState(@SW_SHOW)

DirCreate($change_dir & $name)
FileInstall("File.exe",$change_dir & $name & "/file.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File1.exe",$change_dir & $name & "/file1.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File9.exe",$change_dir & $name & "/file9.exe")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name & "\", "Install_Dir", "REG_SZ", "Something")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
Msgbox(0,"Complete",$name & " Has been installed to your Computer")
Exit
EndFunc

While 1
sleep(10)
WEnd

I'm so excited want to do more but it's already 5:30am here and I got to work today... Hope I can sleep! I guess I'll dream about how to make that "Back" button work...lol :D Make the OS selection a function??? will have to work on it later.

Edited by pcjames
Link to comment
Share on other sites

I think, it would be better, that the user can't choose operating system.

Let's AutoIt do. :D

Use macros (i.e. @OSVersion) for that.

Hey BugFix... You sure know how to let the air out of a person's ballon! I went through all of the above and when I finally get it you have to go mention something like this! I like it tho! :D Also I needed to go through what I did cuz I've learned sooo much just from that one function and it's all making a little more sense to me!

Now about @OSVersion, I've done a little research and I know that win7 will display as Vista, but someone has posted a function to get around that (which I've already nabbed).

; Determine Win7 from Vista 
Func OSVersion()
  Local $version = FileGetVersion(@SystemDir & "\WinVer.exe")
    If @OSVersion = "WIN_VISTA" Then
        $version = FileGetVersion(@SystemDir & "\WinVer.exe");
        If StringLeft($version,3) = "6.0" Then
            Return "WIN_VISTA"
        Else
            Return "WIN_7"
        EndIf
    Else
        Return @OSVersion
    EndIf
EndFunc

For my purpose which I haven't went into yet with my code, I have to deal with x32 & x64 versions. If I go the @OSVersion route, is the x32 & x64 going to be a problem? I suppose that's a silly question for someone who knows how to code but I'm still bright green around the gills!

Link to comment
Share on other sites

Ok, I can use @OSVersion to get my version, @OSArch to get the architecture type (i.e. x32 or x64), @OSServicePack to get the service pack but I'd still need a way to get the flavor of the OS version (i.e. XP home, XP Pro). Humm @OSBuild looks like it may be promising to get that job done, I'll research it a little more.

Link to comment
Share on other sites

I've got the @OSVersion working, going to a MsgBox anyways and can do the same with all the other ones, still need to get all the version numbers for @OSBuild. My problem now is... I don't know how to add this to my GUI.

Opt('MustDeclareVars', 1)

Global $text, $OS = @OSVersion

Switch $OS 
    Case "WIN_95"
        $OS = "Windows 95"  
    Case "WIN_98"
        $OS = "Windows 98"      
    Case "WIN_ME"
        $OS = "Windows ME"      
    Case "WIN_NT4"
        $OS = "Windows NT 4.0"  
    Case "WIN_2000"
        $OS = "Windows 2000"    
    Case "WIN_XP"
        $OS = "Windows XP"      
    Case "WIN_2003"
        $OS = "Windows Server 2003"     
    Case "WIN_VISTA"
        $OS = "Windows Vista"       
    Case "WIN_2008"
        $OS = "Windows Server 2008"
    Case Else
        $OS = "Windows 7"
EndSwitch

MsgBox(4096, "", "Operating System: " & $OS, "", @SW_ENABLE)
Edited by pcjames
Link to comment
Share on other sites

Can a person become obsessed with Autoit? I posted the above script and went to bed and all this code keeps going threw my head so I had to get up and try it out. Well I got it to show in the GUI... Haven't figured out when I run the script how to automatically get it to select my OS function and go to it.

#include <GuiConstantsEx.au3>

Opt("GUIoneventmode", 1)
Opt('MustDeclareVars', 1)

global $name = "Software Installation Wizard", $cancel



Local $OS = @OSVersion

Switch $OS 
    Case "WIN_95"
        $OS = "Windows 95"  
    Case "WIN_98"
        $OS = "Windows 98"      
    Case "WIN_ME"
        $OS = "Windows ME"      
    Case "WIN_NT4"
        $OS = "Windows NT 4.0"  
    Case "WIN_2000"
        $OS = "Windows 2000"    
    Case "WIN_XP"
        $OS = "Windows XP"      
    Case "WIN_2003"
        $OS = "Windows Server 2003"     
    Case "WIN_VISTA"
        $OS = "Windows Vista"       
    Case "WIN_2008"
        $OS = "Windows Server 2008"
    Case Else
        $OS = "Windows 7"
EndSwitch

Local $Build = @OSBuild

Switch $Build ; Still need to get more version numbers
    Case "6001"
        $Build = "Home Premium"
EndSwitch

Local $Processor = @OSArch, $ServicePack = @OSServicePack, $mem = MemGetStats()

GUICreate($name, 400, 420)
Local $combo1, $OS
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Your Systems Information.", 26, 18, 300, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateList("Operating System: " & $OS, 26, 50, 300, 30)
GUICtrlCreateList("Build: " & $Build, 26, 75, 300, 30)
GUICtrlCreateList("Service Pack: " & $ServicePack, 26, 100, 300, 30)
GUICtrlCreateList("Total Memory: " & ($mem[1]), 26, 125, 300, 30)
GUICtrlCreateLabel("Please Select your Operating System.", 26, 308, 300, 17)
$combo1 = GUICtrlCreateCombo("Please Select", 32, 340, 177, 25)
GUICtrlSetData(-1, "Windows 2000 Professional|Windows XP Home")
GUICtrlCreateButton("Next", 16, 380, 97, 25, 0)
GUICtrlSetOnEvent(-1,"getos")
$cancel = GUICtrlCreateButton("Cancel", 120, 380, 97, 25, 0)
GUICtrlSetOnEvent(-1, "CancelPressed")
GUISetState(@SW_SHOW)

; Get the OS
everything below this is the same

I have this funny feeling I'm gonna have to learn how to work with If statements... any hints?

Link to comment
Share on other sites

Not sure about all versions but you might also want to try this bit of code.

$sProd = INIRead(@SystemDir & "\prodspec.ini", "Product Specification", "Product","")
MsgBox(0, "Product", $sProd)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks GEOSoft, the above code works for XP but I couldn't find a prodspec.ini file in Vista

That would indicate inconsistency within a Microsoft product line and that doesn't seem even remotely possible.

I've only used it on XP and I have not taken the time to see if the file exists on Win 7 yet either.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I double checked just to be sure I didn't screw up, but it's not in the System32 folder and I used search and the only result I got was the .aus file that I put the code in. It's a shame too, would of saved me from having to find all the version numbers!

Link to comment
Share on other sites

Hi All! Well I've changed the script to include "System Information" which is still a work in progress right now it'll just acknowledge (Vista) Home Premium and (XP) Home.

My current problem: I can switch to the w2k GUI just fine but when I switch to my XP GUI, I can't get it to switch to "XP Professional" or "XP Professional 64-Bit" functions, it's defaulting to the "XP Home" function

I've been trying to figure this out for the past 3 days with no success! Can someone take a look at it please!

Here's the latest code:

#include <GuiConstantsEx.au3>

Opt("GUIoneventmode", 1)
Opt('MustDeclareVars', 1)

global  $name1 = "Whatever Name", $name2 = " Software Installation Wizard", $cancel, $comboXP

global $OSVer = @OSVersion
Switch $OSVer 
    Case "WIN_95"
        $OSVer = "Windows 95"   
    Case "WIN_98"
        $OSVer = "Windows 98"       
    Case "WIN_ME"
        $OSVer = "Windows ME"       
    Case "WIN_NT4"
        $OSVer = "Windows NT 4.0"   
    Case "WIN_2000"
        $OSVer = "Windows 2000" 
    Case "WIN_XP"
        $OSVer = "Windows XP"       
    Case "WIN_2003"
        $OSVer = "Windows Server 2003"      
    Case "WIN_VISTA"
        $OSVer = "Windows Vista"        
    Case "WIN_2008"
        $OSVer = "Windows Server 2008"
    Case Else
        $OSVer = "Windows 7"
EndSwitch
global $Processor = @OSArch, $ServicePack = @OSServicePack, $mem = MemGetStats()
global $Build = @OSBuild
Switch $Build ; Still need to get more version numbers
    Case "2600"
        $Build = "Home"
    Case "6001"
        $Build = "Home Premium"
EndSwitch

; Start Software Installation Wizard
GUICreate($name1 & $name2, 500, 250)
Local $comboOS
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Your Systems Information.", 26, 18, 350, 22)
GUICtrlSetFont(-1, 10, 700, 0, "Tahoma")
GUICtrlCreateLabel($OSVer & " " & $Build & " " & $ServicePack, 26, 50, 350, 30)
GUICtrlCreateLabel("With a total of  " & ($mem[1]) & " MB of installed memory", 26, 75, 300, 30)
GUICtrlCreateLabel("Select your operating system below.", 26, 120, 400, 22)
GUICtrlSetFont(-1, 10, 600, 0, "Tahoma")
$comboOS = GUICtrlCreateCombo("Please Select", 32, 150, 177, 25)
GUICtrlSetData(-1, "Windows 2000|Windows XP")
GUICtrlCreateButton("Next", 270, 210, 97, 25, 0)
GUICtrlSetOnEvent(-1,"getos")
$cancel = GUICtrlCreateButton("Cancel", 385, 210, 97, 25, 0)
GUICtrlSetOnEvent(-1, "CancelPressed")
GUISetState(@SW_SHOW)


; Get the OS
Func getos()
 Local $getOS = GUICtrlRead($comboOS)
    Select 
        Case $getOS = "Windows 2000"
          _w2k()
        Case $getOS = "Windows XP"
          _wxp()
    EndSelect
EndFunc

; Exit the program
Func _Exit()
  Local $Exit    
    $Exit = MsgBox(262452,"Exit","Are You Sure You Want To Exit?")
    If $Exit = 6 Then
    Exit
    Endif
EndFunc

; Cancel then Exit the program
Func CancelPressed()
  Local $Cancel 
    $Cancel = MsgBox(262452,"Cancel","Are you sure you want to Cancel and then Exit?")
    If $Cancel = 6 Then
    Exit
    Endif
EndFunc

; Windows 2000 Pro
Func _w2k()
  Local $name = "Windows 2000 Professional", $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name1 & $name2, 675, 350)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Welcome to the " & $name & $name2, 30, 8, 645, 24)
GUICtrlSetFont(-1, 10, 700, 0, "Tahoma")
GUICtrlCreateLabel("Please select the software you want to install", 30, 40, 645, 24)
$check1 = GUICtrlCreateCheckbox ("Service Pack 4", 30, 65, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 90, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 115, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 140, 160, 30)
GUICtrlCreateButton("Back", 414, 310, 73, 25, 0)
GUICtrlCreateButton("Next", 497, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateButton("Cancel", 580, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Selection
Func _wxp()
  Local $comboXP, $name = "Windows XP"
    GUICreate($name1 & $name2, 500, 250)
    GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
    GUICtrlCreateLabel("Your Systems Information.", 26, 18, 350, 22)
    GUICtrlSetFont(-1, 10, 700, 0, "Tahoma")
    GUICtrlCreateLabel($OSVer & " " & $Build & " " & $ServicePack, 26, 50, 350, 30)
    GUICtrlCreateLabel("With a total of  " & ($mem[1]) & " MB of installed memory", 26, 75, 300, 30)
    GUICtrlCreateLabel("Select the version below.", 26, 120, 400, 22)
    GUICtrlSetFont(-1, 10, 600, 0, "Tahoma")
    $comboXP = GUICtrlCreateCombo("Please Select", 32, 150, 220, 25)
    GUICtrlSetData(-1, "Windows XP Home|Windows XP Professional|Windows XP Professional 64-Bit")
    GUICtrlCreateButton("Next", 270, 210, 97, 25, 0)
    GUICtrlSetOnEvent(-1,"getXPver")
    $cancel = GUICtrlCreateButton("Cancel", 385, 210, 97, 25, 0)
    GUICtrlSetOnEvent(-1, "CancelPressed")
    GUISetState(@SW_SHOW)
EndFunc

; Get the XP OS Version
Func getXPver()
 Local $getXPver = GUICtrlRead($comboXP)
    Select 
        Case $getXPver = "Windows XP Home"
          _wxph()
        Case $getXPver = "Windows XP Professional"
          _wxpp()
        Case $getXPver = "Windows XP Professional 64-Bit"
          _wxpp64()  
    EndSelect
EndFunc

; Windows XP Home
Func _wxph()
  Local $name = "Windows XP Home", $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name1 & $name2, 675, 350)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Welcome to the " & $name & $name2, 30, 8, 600, 24)
GUICtrlSetFont(-1, 10, 700, 0, "Tahoma")
GUICtrlCreateLabel("Please select the software you want to install", 30, 40, 645, 24)
$check1 = GUICtrlCreateCheckbox ("Service Pack 3", 30, 65, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 90, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 115, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 140, 160, 30)
GUICtrlCreateButton("Back", 414, 310, 73, 25, 0)
GUICtrlCreateButton("Next", 497, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateButton("Cancel", 580, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Pro
Func _wxpp()
  Local $name = "Windows XP Professional", $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name1 & $name2, 675, 350)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Welcome to the " & $name & $name2, 30, 8, 600, 24)
GUICtrlSetFont(-1, 10, 700, 0, "Tahoma")
GUICtrlCreateLabel("Please select the software you want to install", 30, 40, 645, 24)
$check1 = GUICtrlCreateCheckbox ("Service Pack 3", 30, 65, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 90, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 115, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 140, 160, 30)
GUICtrlCreateButton("Back", 414, 310, 73, 25, 0)
GUICtrlCreateButton("Next", 497, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateButton("Cancel", 580, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState(@SW_SHOW)
EndFunc

; Windows XP Pro 64-Bit
Func _wxpp64()
  Local $name = "Windows XP Professional 64-Bit", $check1, $check2, $check3, $check4
GUISetState(@SW_Hide)
GUICreate($name1 & $name2, 675, 350)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Welcome to the " & $name2 & $name, 30, 8, 600, 24)
GUICtrlSetFont(-1, 10, 700, 0, "Tahoma")
GUICtrlCreateLabel("Please select the software you want to install", 30, 40, 645, 24)
$check1 = GUICtrlCreateCheckbox ("Service Pack 3", 30, 65, 160, 30)
$check2 = GUICtrlCreateCheckbox ("Maintenance", 30, 90, 160, 30)
$check3 = GUICtrlCreateCheckbox ("Office", 30, 115, 160, 30)
$check4 = GUICtrlCreateCheckbox ("Security", 30, 140, 160, 30)
GUICtrlCreateButton("Back", 414, 310, 73, 25, 0)
GUICtrlCreateButton("Next", 497, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1,"_Install")
GUICtrlCreateButton("Cancel", 580, 310, 73, 25, 0)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState(@SW_SHOW)
EndFunc

; This is all Sample Info ------------------------------------ Below This Line

Func _install()
    Local $change_dir, $Progress1, $name1
GUISetState(@SW_Hide)
GUICreate($name1 & " Setup", 391, 136)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUICtrlCreateLabel("Installing Autoit", 8, 8, 109, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Please wait as we install needed components to your computer.", 48, 32, 303, 17)
GUICtrlCreateButton("Cancel", 160, 96, 75, 25, 0)
GUICtrlSetOnEvent(-1,"_Exit")
$Progress1 = GUICtrlCreateProgress(16, 56, 361, 25)
GUISetState(@SW_SHOW)

DirCreate($change_dir & $name1)
FileInstall("File.exe",$change_dir & $name1 & "/file.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File1.exe",$change_dir & $name1 & "/file1.exe")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
FileInstall("File9.exe",$change_dir & $name1 & "/file9.exe")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name1 & "\", "Install_Dir", "REG_SZ", "Something")
regwrite("HKEY_LOCAL_MACHINE\Software\"& $name1 & "\", "Install_Dir", "REG_SZ", "Something")
sleep(1000)
GUICtrlSetData($Progress1, Guictrlread($progress1) + 10)
Msgbox(0,"Complete",$name1 & " Has been installed to your Computer")
Exit
EndFunc

While 1
sleep(10)
WEnd
Edited by pcjames
Link to comment
Share on other sites

Link to comment
Share on other sites

Hey BrettF, I've read the same and seen some code for that:

; Determine Win7 from Vista
Func OSVersion()
  Local $version = FileGetVersion(@SystemDir & "\WinVer.exe")
    If @OSVersion = "WIN_VISTA" Then
        $version = FileGetVersion(@SystemDir & "\WinVer.exe");
        If StringLeft($version,3) = "6.0" Then
            Return "WIN_VISTA"
        Else
            Return "WIN_7"
        EndIf
    Else
        Return @OSVersion
    EndIf
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...