ihousden Posted February 24, 2011 Share Posted February 24, 2011 Hi all. Its been a long time since I used Autoit, 5 years at least. Delighted to see its still going strong. I have what I assume will be a dumb question. My gui prompts for a username, pass, and date. This information is used to log you into a system (Resource Scheduler (RS)) and supply the date for a query. Problem is that while the gui is running, the $tdate variable works fine, but outside the function it does not. Run the code to see what im talking about. I need the variable value to cary through after the gui shuts down. MsgBox commands are placed both in and out of the function, yet return different results for $tdate. expandcollapse popup; Includes: #include <IE.au3> #include <Date.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <DateTimeConstants.au3> ; Variables: Dim $RSlogin Dim $RSpass Dim $tdate ; target date for query Gui() MsgBox(0, "Date", $tdate) ; confirm date variable Exit Func Gui() Local $msg, $date, $DTM_SETFORMAT_, $style GUICreate("Script Perameters", 450, 125) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box GUICtrlCreateLabel("Enter your RS Username", 20, 20) $RSlogin = GUICtrlCreateInput("", 250, 15, 150, 20) GUICtrlCreateLabel("Enter your RS Password", 20, 40) $RPass = GUICtrlCreateInput("", 250, 35, 150, 20) GUICtrlCreateLabel("Select query target date", 20, 60) $tdate = GUICtrlCreateDate("", 250, 55, 100, 20) $btn = GUICtrlCreateButton("Ok", 195, 90, 60, 20) $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW $style = "MM/dd/yyyy" $date= GUICtrlSendMsg($tdate, $DTM_SETFORMAT_, 0, $style) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn ExitLoop EndSelect WEnd MsgBox(0, "Date", GUICtrlRead($tdate)) ; confirm date variable GUIDelete() EndFunc Im obviously not properly assigning the date input to the $tdate variable. How is that correctly done? Thanks all. Link to comment Share on other sites More sharing options...
KaFu Posted February 24, 2011 Share Posted February 24, 2011 In the function $tdate is a control, not a value read. Additionally you delete it at the end of the function. Define a Global $tdate_Buffer and fill it before the GUIDelete(). OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-13) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
ihousden Posted February 24, 2011 Author Share Posted February 24, 2011 In the function $tdate is a control, not a value read. Additionally you delete it at the end of the function. Define a Global $tdate_Buffer and fill it before the GUIDelete().Thanks Kafu.Umm, how is that done exactly? I tried adding this to the function, but it didnt work. Global $tdate_Buffer $tdate_Buffer = $tdateHow do I extract the control input to a value?Thanks again. Link to comment Share on other sites More sharing options...
KaFu Posted February 24, 2011 Share Posted February 24, 2011 Before function call Global $tdate_Buffer Before GuiDelete() $tdate_Buffer = GUICtrlRead($tdate) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-13) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
ihousden Posted February 24, 2011 Author Share Posted February 24, 2011 Before function callGlobal $tdate_BufferBefore GuiDelete()$tdate_Buffer = GUICtrlRead($tdate)Thanks KaFu!Worked like a charm. And your response was wicked fast. Thanks so much for providing your expertice. Link to comment Share on other sites More sharing options...
KaFu Posted February 24, 2011 Share Posted February 24, 2011 You're welcome . OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-13) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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