Page 1 of 1

[Dialog/Function] SelectTimeFormat

Posted: 08 Oct 2018, 18:51
by Delta Pythagorean
Just a little something for the user to select a custom format for a date and time.

Here's the function:

Code: Select all

SelectTimeFormat(Hwnd, CustomFormats := "") {
	Gui, DS:New, -MinimizeBox +Owner%Hwnd% +hwndDS
	Gui, DS:Add, ListBox, w330 h120 hwndType g__DS_LB, M/dd/yyyy h:mm:ss tt||dddd, MMMM dd, yyyy|dd-MMM-yy|m/dd/yyyy|h:mm:ss tt|h:mm tt|HH:mm|%CustomFormats%
	Gui, DS:Add, Button, w75 h23 g__DS_Format, &OK
	Gui, DS:Show,, Date Format Select
	WinWaitClose, % "ahk_id " DS
	Return, Time

	__DS_LB:
	__DS_Format:
		If (A_GuiEvent ~= "i)Double") || (A_ThisLabel ~= "i)Format") {
			Gui, DS:Submit
			GuiControlGet, Type,, % Type
			FormatTime, Time,, % Type
		}
		Return

}
And here's an example:

Code: Select all

; > Performance Header Begin::
#NoEnv
#SingleInstance, Force
#KeyHistory, 0
#MaxThreadsPerHotkey, 1
#Persistent
ListLines, Off
SendMode, Input
SetBatchLines, -1
SetWinDelay, -1
SetMouseDelay, -1
SetKeyDelay, -1, -1
SetTitleMatchMode, 2
DetectHiddenWindows, Off
SetWorkingDir, % A_ScriptDir
; > Performance Header End::

Gui, 1:New, -MinimizeBox +HwndHwnd
Gui, 1:Add, Text, w200 vInfo, ----
Gui, 1:Add, Button, w75 h23, Select
Gui, 1:Show,, Date Select
Return

ButtonSelect:
	GuiControl, 1:, Info, % SelectTimeFormat(Hwnd)
	Return

GuiEscape:
GuiClose:
	ExitApp

#Include, SelectTimeFormat.ahk

Re: [Dialog/Function] SelectTimeFormat

Posted: 08 Oct 2018, 19:04
by burque505
@DelPyth, thanks, nice script.
Regards,
burque505