Nunos Posted October 15, 2022 Posted October 15, 2022 expandcollapse popupGUI() Func GUI() Local $msg Local $btnOkay Local $btnClose $GUI = GUICreate("Record Serial Number", 280, 280) ; will create a dialog box that when displayed is centered GUICtrlCreateLabel("Please input the manufacturers name", 15, 25) $inpBoxMFRName = GUICtrlCreateInput("Posiflex", 15, 45, 150, 20) GUICtrlCreateLabel("Please input the model number", 15, 75) $inpBoxModName = GUICtrlCreateInput("", 15, 95, 150, 20) GUICtrlCreateLabel("Please input the serial number", 15, 125) $inpBoxSerialNumber = GUICtrlCreateInput("", 15, 145, 150, 20) GUICtrlCreateLabel("Please input the date of purchase", 15, 175) ;$inpBoxDate = GUICtrlCreateInput("mm/dd/yyyy", 15, 195, 150, 20) $inpBoxDate = _GUICtrlDTP_Create($GUI, 15, 195, 150, 20) _GUICtrlDTP_SetFormat($inpBoxDate, "MM/dd/yyyy") ; the uppercase/lowercase actually matters $btnOkay = GUICtrlCreateButton("Okay", 65, 245, 85, 25) $btnClose = GUICtrlCreateButton("Close", 165, 245, 85, 25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btnClose ;This moves the previously backed up version of SN.ini back to where it should be FileCopy("C:\IDS\SN.ini", @AppDataDir & "\IDS\SN.ini", 1 + 8) ExitLoop Case $msg = $btnOkay ;This writes to the ini file the data you enter in the form IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Computer Name", @ComputerName) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Manufacturer", GUICtrlRead($inpBoxMFRName)) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Model", GUICtrlRead($inpBoxModName)) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Serial", GUICtrlRead($inpBoxSerialNumber)) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Date", GUICtrlRead($inpBoxDate)) ExitLoop EndSelect WEnd EndFunc ;==>GUI I used $inpBoxDate = _GUICtrlDTP_Create($GUI, 15, 195, 150, 20) _GUICtrlDTP_SetFormat($inpBoxDate, "MM/dd/yyyy") ; the uppercase/lowercase actually matters to try to format and get a calender for selecting dates but when I try to read it and record it to an ini file I get Date: 0 IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Date", GUICtrlRead($inpBoxDate)) Not sure what I am missing here.
pixelsearch Posted October 15, 2022 Posted October 15, 2022 (edited) Hello. What I quickly notice is this : * _GUICtrlDTP_Create() returns a handle * GUICtrlRead() requires a control identifier (controlID) as returned by a GUICtrlCreate...() function. Edited October 15, 2022 by pixelsearch typo Danp2 1
Danp2 Posted October 15, 2022 Posted October 15, 2022 See _GUICtrlDTP_GetSystemTime in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs
Solution Nine Posted October 15, 2022 Solution Posted October 15, 2022 I suggest you use GUICtrlCreateDate instead. See 3rd example how to set format with this function. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Nunos Posted October 15, 2022 Author Posted October 15, 2022 Awesome thany you all for helping I appreciate it. I switched it to GUICtrlCreateDate which is now working. 😀 Below is the code incase someone has need of it in the future. expandcollapse popupGUI() Func GUI() Local $msg Local $btnOkay Local $btnClose $GUI = GUICreate("Record Serial Number", 280, 280) ; will create a dialog box that when displayed is centered GUICtrlCreateLabel("Please input the manufacturers name", 15, 25) $inpBoxMFRName = GUICtrlCreateInput("Posiflex", 15, 45, 150, 20) GUICtrlCreateLabel("Please input the model number", 15, 75) $inpBoxModName = GUICtrlCreateInput("", 15, 95, 150, 20) GUICtrlCreateLabel("Please input the serial number", 15, 125) $inpBoxSerialNumber = GUICtrlCreateInput("", 15, 145, 150, 20) GUICtrlCreateLabel("Please input the date of purchase", 15, 175) $inpBoxDate = GUICtrlCreateDate("", 15, 195, 150, 20, $DTS_SHORTDATEFORMAT) $btnOkay = GUICtrlCreateButton("Okay", 65, 245, 85, 25) $btnClose = GUICtrlCreateButton("Close", 165, 245, 85, 25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btnClose ;This moves the previously backed up version of SN.ini back to where it should be FileCopy("C:\IDS\SN.ini", @AppDataDir & "\IDS\SN.ini", 1 + 8) ExitLoop Case $msg = $btnOkay ;This writes to the ini file the data you enter in the form IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Computer Name", @ComputerName) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Manufacturer", GUICtrlRead($inpBoxMFRName)) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Model", GUICtrlRead($inpBoxModName)) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Serial", GUICtrlRead($inpBoxSerialNumber)) IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Date", GUICtrlRead($inpBoxDate)) ExitLoop EndSelect WEnd EndFunc ;==>GUI
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