[Dialog/Function] SelectTimeFormat

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

[Dialog/Function] SelectTimeFormat

08 Oct 2018, 18:51

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

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

burque505
Posts: 1736
Joined: 22 Jan 2017, 19:37

Re: [Dialog/Function] SelectTimeFormat

08 Oct 2018, 19:04

@DelPyth, thanks, nice script.
Regards,
burque505

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 285 guests