faustf Posted December 19, 2012 Share Posted December 19, 2012 hi guy how is possible controll a format of hours?? exemple i have input box and user must insert a valid format 24:24 not must insert 59:85 because give error how is possible?? Link to comment Share on other sites More sharing options...
JohnOne Posted December 19, 2012 Share Posted December 19, 2012 Example. #include <Date.au3> ;Local $sDate = @YEAR & "/" & @MON & "/" & @MDAY & " " & "56" & ":" & @MIN ;Local $sDate = @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN If _DateIsValid($sDate) Then MsgBox(4096, "Valid Date", "The specified date is valid.") Else MsgBox(4096, "Valid Date", "The specified date is invalid.") EndIf Uncomment one of the above to see valid or invalid. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2012 Moderators Share Posted December 19, 2012 faustf, A quick and dirty attempt - I am sure there are better ways out there: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 110, 200, 40) GUICtrlSetLimit(-1, 5) GUICtrlSetFont(-1, 24) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam If BitAND($wParam, 0xFFFF) = $cInput And BitShift($wParam, 16) = 0x300 Then ; $EN_CHANGE Local $sInput = GUICtrlRead($cInput) If $sInput Then $aInput = StringSplit($sInput, "") If Not StringRegExp($aInput[1], "[0-2]") Then $aInput[1] = "" ElseIf $aInput[0] = 2 Then If $aInput[1] = 2 Then If Not StringRegExp($aInput[2], "[0-4]") Then $aInput[2] = "" Else ReDim $aInput[4] $aInput[0] = 3 $aInput[3] = ":" EndIf Else If (Not StringRegExp($aInput[2], "[0-9]")) Then $aInput[2] = "" Else ReDim $aInput[4] $aInput[0] = 3 $aInput[3] = ":" EndIf EndIf ElseIf $aInput[0] = 3 And Not $aInput[3] = ":" Then $aInput[3] = "" ElseIf $aInput[0] = 4 And Not StringRegExp($aInput[4], "[0-5]") Then $aInput[4] = "" ElseIf $aInput[0] = 5 And Not StringRegExp($aInput[5], "[0-9]") Then $aInput[5] = "" EndIf $sInput = "" For $i = 1 To $aInput[0] $sInput &= $aInput[$i] Next GUICtrlSetData($cInput, $sInput) EndIf EndIf EndFunc ;==>_WM_COMMAND M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
faustf Posted December 19, 2012 Author Share Posted December 19, 2012 thankzzz Link to comment Share on other sites More sharing options...
faustf Posted December 19, 2012 Author Share Posted December 19, 2012 little bit bug for sciprt melba23 if you write 22:55 and after correct 2:355 is possible Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2012 Moderators Share Posted December 19, 2012 faustf,I did say it was "quick and dirty" - I am sure there are all sorts of problems with it if you try hard to break it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2012 Moderators Share Posted December 19, 2012 faustf, My final attempt: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) GUISetFont(24) $cInput_1 = GUICtrlCreateInput("", 10, 10, 25, 40) GUICtrlSetLimit(-1, 1) $cInput_2 = GUICtrlCreateInput("", 35, 10, 25, 40) GUICtrlSetLimit(-1, 1) GUICtrlCreateLabel(":", 60, 10, 10, 40) $cInput_3 = GUICtrlCreateInput("", 70, 10, 25, 40) GUICtrlSetLimit(-1, 1) $cInput_4 = GUICtrlCreateInput("", 95, 10, 25, 40) GUICtrlSetLimit(-1, 1) GUISetState() GUICtrlSetState($cInput_1, $GUI_FOCUS) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam If BitShift($wParam, 16) = 0x300 Then ; $EN_CHANGE Switch BitAND($wParam, 0xFFFF) ; ControlID Case $cInput_1 $sInput = GUICtrlRead($cInput_1) If StringRegExp($sInput, "[0-2]") Then If $sInput == "2" Then If Number(GUICtrlRead($cInput_2)) > 4 Then GUICtrlSetData($cInput_2, "") EndIf EndIf GUICtrlSetState($cInput_2, $GUI_FOCUS) Else GUICtrlSetData($cInput_1, "") GUICtrlSetState($cInput_1, $GUI_FOCUS) EndIf Case $cInput_2 $sInput = GUICtrlRead($cInput_2) Switch GUICtrlRead($cInput_1) Case 2 If StringRegExp($sInput, "[0-3]") Then GUICtrlSetState($cInput_3, $GUI_FOCUS) Else GUICtrlSetData($cInput_2, "") GUICtrlSetState($cInput_2, $GUI_FOCUS) EndIf Case Else If StringRegExp($sInput, "[0-9]") Then GUICtrlSetState($cInput_3, $GUI_FOCUS) Else GUICtrlSetData($cInput_2, "") GUICtrlSetState($cInput_2, $GUI_FOCUS) EndIf EndSwitch Case $cInput_3 $sInput = GUICtrlRead($cInput_3) If StringRegExp($sInput, "[0-5]") Then GUICtrlSetState($cInput_4, $GUI_FOCUS) Else GUICtrlSetData($cInput_3, "") GUICtrlSetState($cInput_3, $GUI_FOCUS) EndIf Case $cInput_4 $sInput = GUICtrlRead($cInput_4) If Not StringRegExp($sInput, "[0-9]") Then GUICtrlSetData($cInput_4, "") GUICtrlSetState($cInput_4, $GUI_FOCUS) EndIf EndSwitch EndIf EndFunc M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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