telmob Posted March 1, 2012 Posted March 1, 2012 (edited) I have a GUI function and i have another function after the GUI that calls for some combos, etc inside the GUI. Can i do that? In this particular situation, i need a func for my GUI because i have a password script before to call the GUI if the password is correct. For example: #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _mypw() Func _mypw() $pw = "mypw" $input = InputBox("My Script Name", "Please enter a password", "", "*") If $pw <> $input Then Exit ElseIf $pw = $input Then MainGUI() EndIf EndFunc Func MainGUI() $Form1 = GUICreate("Form1", 193, 106, 568, 331) $Combo1 = GUICtrlCreateCombo("Combo1", 24, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Combo2 = GUICtrlCreateCombo("Combo2", 24, 56, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func ReadCombo() If GUICtrlRead($Combo1) = "" Then $Combo2 = "------" EndFunc Edited March 1, 2012 by telmob
water Posted March 1, 2012 Posted March 1, 2012 Define the variables you need in both functions as Global in the main script: #include <comboconstants.au3> #include <guiconstantsex.au3> #include <windowsconstants.au3> Global $Form1, $Combo1, $Combo2 MainGUI() Func MainGUI() $Form1 = GUICreate("Form1", 193, 106, 568, 331) $Combo1 = GUICtrlCreateCombo("Combo1", 24, 24, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) $Combo2 = GUICtrlCreateCombo("Combo2", 24, 56, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>MainGUI Func ReadCombo() If GUICtrlRead($Combo1) = "" Then $Combo2 = "------" EndFunc ;==>ReadCombo My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
telmob Posted March 1, 2012 Author Posted March 1, 2012 Damn... it's like 2k variables... lol I'll try it. Thanks man!
water Posted March 1, 2012 Posted March 1, 2012 2k variables? Then I would suggest to hold the ControlIDs in an array. Can you post a screenshot of your GUI or some code where you create some of the 2k variables? My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
BrewManNH Posted March 1, 2012 Posted March 1, 2012 Unless you have 2000 comboboxes, and not entries in a combobox, the combo only has one controlid, the items are just read from it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
telmob Posted March 1, 2012 Author Posted March 1, 2012 (edited) This is part of the gui, there are more windows like this one. Edit: Ok, just followed the errors and 'globalized' all the missing stuff. Just a couple of hundreds lol Now it seems everything's working so far. Thank you soooo much Edited March 1, 2012 by telmob
BrewManNH Posted March 1, 2012 Posted March 1, 2012 BTW, your password function isn't going to work very well for you. The user only gets one shot at entering the correct password, and after that the script will just go into an endless While/Wend loop the way it's written in your demo. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
water Posted March 1, 2012 Posted March 1, 2012 (edited) Just a quick and dirty example how to create a GUI using a loop and storing the ControlIDs in a table as well as storing the input data in a table.expandcollapse popup#include <GUIConstantsEx.au3> #include <array.au3> $sTitle = "... Wellen Data Bank ..." #region ### Position and dimension of controls ### Global Global $iLLeft = 16, $iLTop = 74, $iLWidth = 191, $iLHeight = 17, $iLSpace = 17 ; Label control Global $iILeft = 208, $iITop = 72, $iIWidth = 209, $iIHeight = 21, $iISpace = 13, $iIHSpace = 10 ; Input control #endregion ### Position and dimension of controls ### Global $aGUIlabels[15] = ["Label1", "Label2", "Label3", "Label4", "Label5", "Label6", "Label7", "Label8", "Label9", "Label10", "Label11", "Label12", "Label13", "Label14", "Label15"] Global $aGUIControls[15][4] ; array holding the ControlIDs. Row and column on the GUI start withe 1 but the arrays elements start with 0. Row 2 Column 3 is $aGUIControls[1][2] Global $aGUIInput[15][4]; array holding the Input from the Controls. Numbering ase in $aGUIControls #region ### START Koda GUI section ### Global $hGUI = GUICreate($sTitle, 1200, 600, 192, 124) For $iLine = 0 To 14 GUICtrlCreateLabel($aGUIlabels[$iLine], $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight) $aGUIControls[$iLine][0] = GUICtrlCreateInput($aGUIControls[$iLine][0], $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight) $aGUIControls[$iLine][1] = GUICtrlCreateInput($aGUIControls[$iLine][1], $iILeft + 1 * ($iIWidth + $iIHSpace), $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight) $aGUIControls[$iLine][2] = GUICtrlCreateInput($aGUIControls[$iLine][2], $iILeft + 2 * ($iIWidth + $iIHSpace), $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight) $aGUIControls[$iLine][3] = GUICtrlCreateInput($aGUIControls[$iLine][3], $iILeft + 3 * ($iIWidth + $iIHSpace), $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight) Next GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case 0 Case $GUI_EVENT_CLOSE _ArrayDisplay($aGUIInput) Exit Case Else For $i = 0 To UBound($aGUIControls, 1)-1 For $j = 0 To UBound($aGUIControls, 2)-1 If $aGUIControls[$i][$j] = $iMsg Then $aGUIInput[$i][$j] = GUICtrlRead($iMsg) ; Read all ControlIDs (which are stored in the array) and put the read data into another array ExitLoop 2 EndIf Next Next EndSwitch WEnd Edited March 7, 2012 by water My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
telmob Posted March 1, 2012 Author Posted March 1, 2012 On 3/1/2012 at 4:13 PM, 'BrewManNH said: BTW, your password function isn't going to work very well for you. The user only gets one shot at entering the correct password, and after that the script will just go into an endless While/Wend loop the way it's written in your demo.Yes, i know, that was just an example. I've made a proper password box with MD5 in an encrypted file. It might not be the safest solution but it's working alright.@water -> Great solution man. I'll spend some time fixing my script but i believe it's worh it.
telmob Posted March 1, 2012 Author Posted March 1, 2012 (edited) BrewManNH, my password script:expandcollapse popup#include <Crypt.au3> #include <Constants.au3> #include <GuiMenu.au3> $HashFile=@ScriptDir & "dataconfig.ini" LoginForm() Func LoginForm() $FormAccess = GUICreate("Acesso Wellen", 210, 170,-1, -1, $WS_SIZEBOX) GUISetIcon(@ScriptDir & "Wellen.ico", -1) $Group1 = GUICtrlCreateGroup("", 5, 1, 200, 108) $UsernameLabel = GUICtrlCreateLabel("Usuário:", 10, 15, 43, 17, 0) $UsernameCheck = GUICtrlCreateInput("", 10, 30, 190, 18, $GUI_SS_DEFAULT_INPUT) GUICtrlSetState(-1, 256) $PasswordLabel = GUICtrlCreateLabel("Senha:", 10, 53, 38, 17, 0) $PasswordCheck = GUICtrlCreateInput("", 10, 68, 190, 18, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $AcessDeniedLabel = GUICtrlCreateLabel("Acesso negado!", 12, 90, 100, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetState(-1, $GUI_HIDE) $AcessGrantedLabel = GUICtrlCreateLabel("Acesso concedido!", 12, 90, 120, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) GUICtrlSetState(-1, $GUI_HIDE) $ButtonOk = GUICtrlCreateButton("&OK", 70, 115, 55, 25, $BS_NOTIFY) GUICtrlSetState(-1, 512) $ButtonCancel = GUICtrlCreateButton("&Cancel", 130, 115, 75, 25, $BS_NOTIFY) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonCancel Exit Case $ButtonOk _Decrypt() $Hash=IniRead($HashFile, GUICtrlRead($UsernameCheck), "Hash", "") $HashTrimmed="0x"&StringTrimLeft(StringTrimRight($Hash,3),1) $UserExists=IniReadSection($HashFile, GUICtrlRead($UsernameCheck)) If $UsernameCheck<>"" And $UserExists<>"" And _Crypt_HashData(GUICtrlRead($PasswordCheck),$CALG_MD5)=$HashTrimmed Then Global $FirstUserNameFind = StringInStr(IniRead(@ScriptDir & "dataconfig.ini", GUICtrlRead($UsernameCheck), "Nome", ""), " ") Global $FirstUserNameResult = StringLeft(IniRead(@ScriptDir & "dataconfig.ini", GUICtrlRead($UsernameCheck), "Nome", ""), $FirstUserNameFind) Global $FullUserNameFind = IniRead(@ScriptDir & "dataconfig.ini", GUICtrlRead($UsernameCheck), "Nome", "") Global $UserQualif=GUICtrlRead($UsernameCheck) _Crypt() GUICtrlSetState($AcessDeniedLabel, $GUI_HIDE) GUICtrlSetState($AcessGrantedLabel, $GUI_SHOW) Sleep(1000) GUIDelete() MainForm() ElseIf $UserExists="" OR _Crypt_HashData(GUICtrlRead($PasswordCheck),$CALG_MD5)<>$Hash Then GUICtrlSetState($AcessDeniedLabel, $GUI_SHOW) Sleep(1000) GUICtrlSetState($AcessDeniedLabel, $GUI_HIDE) _Crypt() EndIf EndSwitch WEnd EndFunc Func _Decrypt() $success=_Crypt_DecryptFile($HashFile, @ScriptDir & "dataconfig2.ini", "crypt", $CALG_RC4) FileDelete($HashFile) FileMove(@ScriptDir & "dataconfig2.ini", $HashFile) EndFunc Func _Crypt() $success=_Crypt_EncryptFile($HashFile, @ScriptDir & "dataconfig2.ini", "crypt", $CALG_RC4) FileDelete($HashFile) FileMove(@ScriptDir & "dataconfig2.ini", $HashFile) EndFunc Edited March 1, 2012 by telmob
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