I dream for (quite) a long time of a date picker in Prompt for User Action (an easy KM general purpose GUI in fact), with immediate benefit of avoiding main date validation...
For the time being, is some HTML+Java(script) in Custom HTML Prompt Action can do some part of the job (even with European/French date )?
There are several ways the Prompt for User Input action should be extended. Things like:
Multi-line Text Areas
Date Picker
Color Picker perhaps
New/Open File/Folder selection
Probably more. They are on the todo list, and may come at some point. Part of the purpose of the Custom HTML Prompt is to allow a lot of these to be written in the mean time - even though its much more challenging to write such things than it would be if they were native in the Prompt for User Input action.
Perhaps someone will take up the challenge and write up something that can generate custom Custom HTML Prompts. Now that would be very meta.
I don't know if Keyboard Maestro can be made to run it natively (Peter?), but you can save it as an applet and launch the applet from Keyboard Maestro then return the date to a Keyboard Maestro variable.
You can try it out by running in in the Script Editor.app β you MUST use β^R to βRun in Foregroundβ.
-Chris
# Author: Shane Stanley
use AppleScript version "2.3.1"
use scripting additions
use framework "Foundation"
use framework "AppKit"
set theApp to path to frontmost application as text
if not (current application's NSThread's isMainThread()) as boolean then
display alert "This script must be run from the main thread." buttons {"Cancel"} as critical
error number -128
end if
-- create a view
set theView to current application's NSView's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, 100, 200))
-- create date picker
set datePicker to current application's NSDatePicker's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, 100, 100))
-- set style: choices are NSTextFieldAndStepperDatePickerStyle, NSClockAndCalendarDatePickerStyle, or NSTextFieldDatePickerStyle
datePicker's setDatePickerStyle:(current application's NSClockAndCalendarDatePickerStyle)
-- set elements: choices include NSHourMinuteDatePickerElementFlag, NSHourMinuteSecondDatePickerElementFlag, NSTimeZoneDatePickerElementFlag, NSYearMonthDatePickerElementFlag, and NSEraDatePickerElementFlag
datePicker's setDatePickerElements:((current application's NSYearMonthDayDatePickerElementFlag) + (current application's NSHourMinuteSecondDatePickerElementFlag as integer))
-- set initial date
datePicker's setDateValue:(current application's NSDate's |date|())
-- get the size it needs
set theSize to datePicker's fittingSize()
--resize the picker and view accordingly
theView's setFrameSize:theSize
datePicker's setFrameSize:theSize
-- add the picker to the view
theView's setSubviews:{datePicker}
-- create an alert
set theAlert to current application's NSAlert's alloc()'s init()
-- set up alert
tell theAlert
its setMessageText:"Pick a date"
its setInformativeText:"Any date"
its addButtonWithTitle:"OK"
its addButtonWithTitle:"Cancel"
its setAccessoryView:theView
end tell
-- show alert in modal loop
set returnCode to theAlert's runModal()
if returnCode = (current application's NSAlertSecondButtonReturn) then error number -128
-- retrieve date
set theDate to datePicker's dateValue() as date
I got it to work! Yes, I was saving it as an AppleScript not saving it as an Application. Thank you for the clarification :), I didn't quite understand when I read it above.