Global $sDate = _InputDateBox(1, 'Kopier-Datum') If @error Then Exit ; Wenn der Benutzer auf Abbrechen geklickt hat, Programm beenden ConsoleWrite('Datum: "' & $sDate & '"' & @CR & 'Error: ' & @error & @CR) ;=============================================================================== ; Function Name: _InputDateBox([$iFormat][, $sTitle][, $sText][, $sDefaultDate][, $hParent]) ; Description: Fragt den Benutzer nach Datum oder Datum und Uhrzeit und gibt dies als String zurück ; Parameter(s): $iFormat = 0 oder 1 ; bei 0 wird nur nach dem Datum gefragt (Uhrzeit wird dann als "000000" zurückgegeben) ; bei 1 wird nach Datum und Uhrzeit gefragt ; Requirement: - ; Return Value(s): bei Erfolg = String in Form von "YYYYMMDDhhmmss" ; bei Abbruch = Leerstring und @error = 1 ; Author(s): Oscar (www.autoit.de) ;=============================================================================== Func _InputDateBox($iFormat = 1, $sTitle = '', $sText = '', $sDefaultDate = '', $hParent = '') If $iFormat < 0 Or $iFormat > 1 Then $iFormat = 1 If $sTitle = '' Or $sTitle = Default Then $sTitle = 'Datum-Box' If $sText = '' Or $sText = Default Then $sText = 'Bitte Datum auswählen!' If $iFormat Then $sText = 'Bitte Datum und Uhrzeit auswählen!' Local $iOnEventMode = Opt('GUIOnEventMode', 0), $sRetDate = '', $iError = 0 Local $hGui = GUICreate($sTitle, 260 + $iFormat * 85, 130, Default, Default, Default, 8, $hParent) GUISetBkColor(0xCCCCCC, $hGui) GUISetIcon('shell32.dll', 24, $hGui) GUICtrlCreateGroup($sText, 10, 20, 240 + $iFormat * 85, 70) GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5) GUICtrlCreateIcon('shell32.dll', -21, 30, 48, 32, 32) Local $idDate = GUICtrlCreateDate($sDefaultDate, 75, 49, 150 + $iFormat * 85, 30, $iFormat) GUICtrlSetFont(-1, 14, 400, 0, 'Verdana', 5) If $iFormat Then Local $DTM_SETFORMAT_ = 0x1032 Local $sStyle = 'dd.MM.yyyy HH:mm:ss' GUICtrlSendMsg($idDate, $DTM_SETFORMAT_, 0, $sStyle) EndIf GUICtrlCreateGroup('', -99, -99, 1, 1) Local $idOk = GUICtrlCreateButton('Ok', 100 + $iFormat * 85, 100, 60, 25, 1) ; <- Value 1 = $BS_DEFPUSHBUTTON Local $idCancel = GUICtrlCreateButton('Abbrechen', 170 + $iFormat * 85, 100, 80, 25) GUISetState(@SW_SHOW, $hGui) While True Switch GUIGetMsg() Case $idCancel, -3 ; <- Value -3 = $GUI_EVENT_CLOSE $iError = 1 ExitLoop Case $idOk $sRetDate = StringRegExpReplace(GUICtrlRead($idDate), '(\d{2})\.(\d{2})\.(\d{4}).*', '$3$2$1') If $iFormat Then $sRetDate &= StringRegExpReplace(GUICtrlRead($idDate), '\d{2}\.\d{2}\.\d{4} (\d{2}):(\d{2}):(\d{2})', '$1$2$3') Else $sRetDate &= '000000' EndIf ExitLoop EndSwitch WEnd GUIDelete($hGui) Opt('GUIOnEventMode', $iOnEventMode) Return SetError($iError, 0, $sRetDate) EndFunc ;==>_InputDateBox