Win: W11 Version 22H2 (Build 22622.601)
Is this a Windows
Code: Select all
#Requires AutoHotkey v2.0-beta
Main := Gui(, "DateTime")
Main.MarginX := 10
Main.MarginY := 10
Main.AddText("xm ym w300 0x200", "Start Datum")
MainDT := Main.AddDateTime("xm y+3 w300 Range20201001 ChooseNone", "LongDate")
Main.OnEvent("Close", (*) => ExitApp)
Main.Show()
MainDT.Value := GetLastMonday() ; Changes the date quietly
OnMessage 0x0100, WM_KEYDOWN
WM_KEYDOWN(wParam, *)
{
switch wParam
{
case 0x71: MainDT.Value := Today() ; F2 -> Changes the date quietly
case 0x72: MainDT.Value := GetThisMonday() ; F3 -> Changes the date quietly
case 0x73: MainDT.Value := GetLastMonday() ; F4 -> Changes the date and opens the date picker
}
}
Today()
{
return SubStr(A_Now, 1, 8) "000000"
}
GetThisMonday()
{
WDay := FormatTime(A_Now, "WDay") - 1
return SubStr(DateAdd(A_Now, -((WDay - 1 = -1 ? 6 : WDay - 1)), "Days"), 1, 8) "000000"
}
GetLastMonday()
{
WDay := FormatTime(A_Now, "WDay") - 1
return SubStr(DateAdd(A_Now, -(7 + (WDay - 1 = -1 ? 6 : WDay - 1)), "Days"), 1, 8) "000000"
}
Edit:
It looks like F4 is causing this strange behavior. Even without having set the F4 hotkey, it opens the DatePicker
Code: Select all
WM_KEYDOWN(wParam, *)
{
switch wParam
{
case 0x71: MainDT.Value := Today() ; F2 -> Changes the date quietly
case 0x72: MainDT.Value := GetThisMonday() ; F3 -> Changes the date quietly
;case 0x73: nothing ; F4 -> Still opens the DatePicker even if not set
case 0x74: MainDT.Value := GetLastMonday() ; F5 -> Changes the date quietly
}
}
Edit:
It is a windows "feature".. wtf