Displaying calendar by macro

Hi!
Is there a way to display a calendar from a date field in a Base form using a macro (basic macro) when it receives focus?
I’m able to display other dropdown fields (combobox or listbox) using
CreateObject(“WScript.Shell”).SendKeys “^%{DOWN}”
But with calendar I can’t, and I wanted!
Thank you so much!

Ask/Guide - How to use the Ask site - The Document Foundation Wiki #More_details

From this I would assume, you are on Windows and use some pre-Powershell script to send keystrokes to LibreOffice.
.
What I don’t know is, if you already have a calendar-widget not opening from script or need some kind of calendar-widget to use.
Another question would be, if a simple listbox for a certain range of dates would be a possible solution. You obviously can handle them.
.
Useful would be a sample document and at least version of LO. The used database may also be important.

Sorry!
Version: 26.2.1.2 (X86_64)
Build ID: 620(Build:2)
CPU threads: 16; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: es-ES
Calc: CL threaded
Excuse my English!
I can’t give an example because it’s not working, but I’m trying a basic macro that, upon exiting a control, sets the focus to a date control with its dropdown menu enabled. When it receives focus, the dropdown menu would activate and display the calendar.
WScript.Shell.SendKeys “^%{DOWN}” works for listboxes and comboboxes, but not for date controls.

I don’t know how to work with WSH. But did a manual test in a date control with focus set
Alt 
and it opens up.
So, are you sure you have got this control referenced by the WSH?
 
LO 24.2.7.2 (X86_64)
OS: Ubuntu package version: 4:24.2.7-0ubuntu0.24.04.4

WshShell is considered a deprecated object by the developer, the description of the SendKeys method is currently here.
LibreOffice has a cross-platform equivalent of the SendKey method, see for example here.

Yes, I know. Just 've never used it.
But OP uses, so…

But if “^%{DOWN}” = Alt  works for List & Combo Boxes, I’m just checking whether the WS object is pointing to (referencing) the Calendar Control :thinking:

So, following @sokol92’s informations and Google AI’s instructions, code to show the calendar when Date Control gets focus (event = When receiving focus).

Option Explicit
Sub Simulate_Alt_ArrowDown()
REM Simulate Alt + Arrow Down Key press
	Dim W As Object, Tk As Object
	Dim oKeyEvent As New com.sun.star.awt.KeyEvent
	On Error GoTo Erro
	REM GET CURRENT WINDOW:
	W = ThisComponent.CurrentController.Frame.getContainerWindow()
	Tk = W.getToolkit()
	REM CONFIGURE THE KEY EVENT:
	oKeyEvent.Source = W
	oKeyEvent.Modifiers	= com.sun.star.awt.KeyModifier.MOD2
	oKeyEvent.KeyCode	= com.sun.star.awt.Key.DOWN
	REM SIMULATE PRESS & RELEASE:
	Tk.keyPress(oKeyEvent)
	Tk.keyRelease(oKeyEvent)
	Exit Sub
	Erro: MsgBox "ERRO " & Err & Chr(10) & "na linha " & Erl
End Sub

I tried it directly in the event when receive focus and it works properly.
Also works calling it from other macro when the macro put the focus in the control and the event when receiving focus is empty.
I only added a bit of code in order to stop the macro when the control has something written ( a date, of course)
Many many thanks!