aerilus Posted June 26, 2013 Share Posted June 26, 2013 I'm working on my first script I have the skeleton set up and working. it pretty much runs a silent installer with a different argument per radio button. the first thing I am having trouble with is getting the gui to be destroyed after the ok button is hit. the second thing is that after waiting for the process started by pressing the ok button to finish i would like it to write a registry entry. it seems like I need a nested if statement but when I try something like that I light up like a christmas tree with syntax errors. any help is appreciated even if someone could just point me to some sample code that might be applicable. everything I can find seems to focus more on snippets rather than how to tie them together. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=c:/test6.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Denton\Documents\Form1.kxf $Form1 = GUICreate("Printer Install", 350, 446, 192, 124) $Label1 = GUICtrlCreateLabel("Please selct the printer you would like to install then click OK.", 16, 8, 292, 17) $Student_Accounts = GUICtrlCreateRadio("Student_Accounts", 24, 32, 113, 17) $Campbell = GUICtrlCreateRadio("Campbell", 24, 64, 113, 17) $Health_Center = GUICtrlCreateRadio("Health_Center", 24, 96, 113, 17) $Admissions = GUICtrlCreateRadio("Admissions", 24, 128, 113, 17) $Fin_Aid = GUICtrlCreateRadio("Fin_Aid", 24, 160, 113, 17) $Odell = GUICtrlCreateRadio("Odell", 24, 192, 113, 17) $Proctor_East = GUICtrlCreateRadio("Proctor_East", 24, 224, 113, 17) $Registar = GUICtrlCreateRadio("Registar", 24, 256, 113, 17) $Career_Center = GUICtrlCreateRadio("Career_Center", 24, 288, 113, 17) $Reynolds = GUICtrlCreateRadio("Reynolds", 24, 320, 113, 17) $Cowan = GUICtrlCreateRadio("Cowan", 160, 32, 113, 17) $Business_Office = GUICtrlCreateRadio("Business_Office", 160, 64, 113, 17) $Hanes_Gym = GUICtrlCreateRadio("Hanes_Gym", 160, 96, 113, 17) $Institutional_Advancement = GUICtrlCreateRadio("Institutional_Advancement", 160, 128, 150, 17) $Library = GUICtrlCreateRadio("Library", 160, 160, 113, 17) ;$Radio16 = GUICtrlCreateRadio("Radio16", 160, 192, 113, 17) ;$Radio17 = GUICtrlCreateRadio("Radio17", 160, 224, 113, 17) ;$Radio18 = GUICtrlCreateRadio("Radio18", 160, 256, 113, 17) $Label2 = GUICtrlCreateLabel("*****enter you account code here******", 160, 224) $Account = GUICtrlCreateInput("", 160, 256) $OK = GUICtrlCreateButton("OK", 152, 312, 75, 25) $Label3 = GUICtrlCreateLabel("Please enter your copier account code before pressing OK. After pressing OK select yess at the prompt then wait a few seconds for the printer installer to pop up", 16, 360, 300, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE ;Destroy the GUI including the controls GUIDelete() ;Exit the script Exit Case $msg = $OK If GUICtrlRead($Proctor_East) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.22.0.224 /port:10.22.0.224") If GUICtrlRead($Student_Accounts) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.217 /port:10.5.0.217") If GUICtrlRead($Campbell) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.26.0.224 /port:10.26.0.224") If GUICtrlRead($Health_Center) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.23.0.224 /port:10.23.0.224") If GUICtrlRead($Admissions) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.30.0.224 /port:10.30.0.224")If GUICtrlRead($Fin_Aid) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.224 /port:10.5.0.224") If GUICtrlRead($Odell) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.33.0.224 /port:10.33.0.224") If GUICtrlRead($Registar) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.219 /port:10.5.0.219") If GUICtrlRead($Career_Center) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.218 /port:10.5.0.218") If GUICtrlRead($Reynolds) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.41.0.224 /port:10.41.0.224") If GUICtrlRead($Cowan) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.32.0.224 /port:10.32.0.224") If GUICtrlRead($Business_Office) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.220 /port:10.5.0.220") If GUICtrlRead($Hanes_Gym) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.28.0.224 /port:10.28.0.224") If GUICtrlRead($Institutional_Advancement) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.221 /port:10.5.0.221") If GUICtrlRead($Library) = $GUI_CHECKED Then ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.20.0.224 /port:10.20.0.224") GUIDelete($Form1) EndSelect WEND While 1 $msg2 = GUICtrlRead($Account) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Lexmark Universal v2 XL\PrinterDriverData", "AccountTrackAccountNumber", "REG_SZ", $msg2) WEnd Link to comment Share on other sites More sharing options...
UndefinedVar Posted June 26, 2013 Share Posted June 26, 2013 (edited) to destroy your GUI, but this will not end the program. GUIDelete($Form1) And I don't understand why you put loop in here While 1 $msg2 = GUICtrlRead($Account) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Lexmark Universal v2 XL\PrinterDriverData", "AccountTrackAccountNumber", "REG_SZ", $msg2) WEnd Edited June 26, 2013 by UndefinedVar Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 26, 2013 Moderators Share Posted June 26, 2013 I would personally do a nested Case statement for readability sake, rather than a bunch of Ifs. Like so: Case $msg = $OK Select Case GUICtrlRead($Proctor_East) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.22.0.224 /port:10.22.0.224") Case GUICtrlRead($Student_Accounts) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.217 /port:10.5.0.217") Case GUICtrlRead($Campbell) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.26.0.224 /port:10.26.0.224") Case GUICtrlRead($Health_Center) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.23.0.224 /port:10.23.0.224") Case GUICtrlRead($Admissions) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.30.0.224 /port:10.30.0.224") ;Case... EndSelect GUIDelete($Form1) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
aerilus Posted June 27, 2013 Author Share Posted June 27, 2013 thank you for your help, there is no reason its in a different while loop just ignorance, I moved to the nested case structure and put the guidelete right after. I moved the regwrite into the same while loop. . Now my problem is that the regwrite wont pick up the variable $msg2. if i put something static there it will write it, but it will not put whats in the gui input and write it to the reg. I get the feeling its something to do with my expression stucture. When I am seeing other variables inside functions they are preceded by "&" but looking through the help file and searching "variables inside functions" isn't netting me the reason why. I know its expecting something like "1234" and what I am seeing people do is something like "123" & $4 but apparently "" & $msg2 isn't the write way to accomplish what I want because it throws syntax errors at me expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=c:/test6.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Denton\Documents\Form1.kxf $Form1 = GUICreate("Printer Install", 350, 446, 192, 124) $Label1 = GUICtrlCreateLabel("Please selct the printer you would like to install then click OK.", 16, 8, 292, 17) $Student_Accounts = GUICtrlCreateRadio("Student_Accounts", 24, 32, 113, 17) $Campbell = GUICtrlCreateRadio("Campbell", 24, 64, 113, 17) $Health_Center = GUICtrlCreateRadio("Health_Center", 24, 96, 113, 17) $Admissions = GUICtrlCreateRadio("Admissions", 24, 128, 113, 17) $Fin_Aid = GUICtrlCreateRadio("Fin_Aid", 24, 160, 113, 17) $Odell = GUICtrlCreateRadio("Odell", 24, 192, 113, 17) $Proctor_East = GUICtrlCreateRadio("Proctor_East", 24, 224, 113, 17) $Registar = GUICtrlCreateRadio("Registar", 24, 256, 113, 17) $Career_Center = GUICtrlCreateRadio("Career_Center", 24, 288, 113, 17) $Reynolds = GUICtrlCreateRadio("Reynolds", 24, 320, 113, 17) $Cowan = GUICtrlCreateRadio("Cowan", 160, 32, 113, 17) $Business_Office = GUICtrlCreateRadio("Business_Office", 160, 64, 113, 17) $Hanes_Gym = GUICtrlCreateRadio("Hanes_Gym", 160, 96, 113, 17) $Institutional_Advancement = GUICtrlCreateRadio("Institutional_Advancement", 160, 128, 150, 17) $Library = GUICtrlCreateRadio("Library", 160, 160, 113, 17) ;$Radio16 = GUICtrlCreateRadio("Radio16", 160, 192, 113, 17) ;$Radio17 = GUICtrlCreateRadio("Radio17", 160, 224, 113, 17) ;$Radio18 = GUICtrlCreateRadio("Radio18", 160, 256, 113, 17) $Label2 = GUICtrlCreateLabel("*****enter you account code here******", 160, 224) $Account = GUICtrlCreateInput("", 160, 256) $OK = GUICtrlCreateButton("OK", 152, 312, 75, 25) $Label3 = GUICtrlCreateLabel("Please enter your copier account code before pressing OK. After pressing OK select yess at the prompt then wait a few seconds for the printer installer to pop up", 16, 360, 300, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE ;Destroy the GUI including the controls GUIDelete() ;Exit the script Exit Case $msg = $OK Select Case GUICtrlRead($Proctor_East) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.22.0.224 /port:10.22.0.224") Case GUICtrlRead($Student_Accounts) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.217 /port:10.5.0.217") Case GUICtrlRead($Campbell) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.26.0.224 /port:10.26.0.224") Case GUICtrlRead($Health_Center) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.23.0.224 /port:10.23.0.224") Case GUICtrlRead($Library) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.20.0.224 /port:10.20.0.224") Case GUICtrlRead($Admissions) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.30.0.224 /port:10.30.0.224") Case GUICtrlRead($Fin_Aid) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.224 /port:10.5.0.224") Case GUICtrlRead($Odell) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.33.0.224 /port:10.33.0.224") Case GUICtrlRead($Registar) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.219 /port:10.5.0.219") Case GUICtrlRead($Career_Center) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.218 /port:10.5.0.218") Case GUICtrlRead($Reynolds) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.41.0.224 /port:10.41.0.224") Case GUICtrlRead($Cowan) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.32.0.224 /port:10.32.0.224") Case GUICtrlRead($Business_Office) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.220 /port:10.5.0.220") Case GUICtrlRead($Hanes_Gym) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.28.0.224 /port:10.28.0.224") Case GUICtrlRead($Institutional_Advancement) = $GUI_CHECKED ShellExecutewait(@ScriptDir & "\LexmarkPkgInstall.exe", "/address:10.5.0.221 /port:10.5.0.221") EndSelect GUIDelete($Form1) EndSelect $msg2 = GUICtrlRead($Account) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Lexmark Copier\PrinterDriverData", "AccountTrackAccountNumber", "REG_SZ", $msg2) WEND 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