Hi Craig and Others,
The AppleScript for saying time does not pay attention to the "Use a 24-hour
clock" check box on the Clock tab of the "Date & Time" menu under System
Preferences. That check box only affects the way time is displayed on the
status bar menu. Furthermore, the format of the string variables for time
returned in the AppleScript is actually set by your country preferences under
the System Preferences "Language & Text" menu under the "Formats" pane. If you
navigate to the "Date & Time" tab of the "Date & Time" menu, you'll find a
statement "To set date and time formats, use Language & Text preferences."
followed by an "Open Language & Text…" button. The "Formats" tab of the
"Language & Text" menu of System Preferences has a pop up button for "Region"
(e.g., "United States", "United Kingdom", etc.), and the rest of the pane gives
sample formats under "Dates", "Times", "Numbers", and "Currency".
What I had to do to get time announced on a 24 hour clock was both create a
custom format for my region by pressing (VO-Space) the "Customize" button on
the section for "Times" under my region ("United States"), and also write a
replacement AppleScript to announce the time. The difficult part was actually
customizing the time format, since you're supposed to drag and drop elements
for the format you want -- so that instead of "7:08 PM" you have "19:08". I
think the way that I did this was by copying the element for "19" from the
customized Time format setting for the "United Kingdom" region, and then
pasting it into the time fields for the customized "United States" region. The
sequence was something like this:
1) Navigate to the "Language & Text" menu of "System Preferences" and go to the
"Formats" tab.
2) Set the Regions pop up button to "United Kingdom"
3) Navigate to the "Times" section and press (VO-Space) the "Customize" button
4) The dialog window will say "Type text and drag time elements to create a
custom format." and there will be sample short, medium, long, and full time
formats. Interact with the first group of these, which is the short format.
Then VO-Space to highlight the group. The first element will be "19" -- or some
hour field number for the 24 hour clock. Bring up the context menu
(VO-Shift-M) and choose the "Copy" option.
5) Press the "Escape" key (top left corner of English language keyboard) to
cancel and leave the dialog window. (Or, you can navigate to the "Cancel"
button and press it with VO-Space.)
6) Set the Regions pop up button to "United States"
7) Navigate to the "Times" section and press (VO-Space) the "Customize" button
8) Navigate to each of the short, medium, long, and full time formats in turn.
Interact with each group, VO-Space, then on the first element, which will be
"7" -- or some hour field number for the 12 hour clock -- bring up the context
menu (VO-Shift-M) and choose the "Paste" option to replace this with the 24
hour clock value. You'll have to do this for the hour element of each of the
four format fields, and you'll also have to use the context menu to "cut" the
"PM" options.
9) Press (VO-Space) the "OK" button to confirm your changes.
You should find that your Region pop up button is now set to "Custom", but that
all the formats are the same, except that your time format uses a 24 hour clock.
Here's a sample AppleScript that will announce the time. It has seconds
announced (so that the format for retrieving this can be shown), but you can
just delete the last variable in the "return" line to remove it. You can also
delete the initial announcement for "The current time is" in the first line's
"say" command. What you'll find is that if you change the Regions pop up
button to "United States", the time will be announced in 12-hour time format.
Note that this means the arguments in the AppleScript are specific to the time
format that has been set up, and that you cannot use the script in unmodified
form with an arbitrary region format. Two years ago when I set this up in
Leopard after a lengthy discussion with Paul Hopewell on the mac-access list,
we found that the solution for a UK region time script would have to be
different. You'll have to experiment with customizing the settings for time
format. I did this under Leopard, and assigned a shortcut to announce the time
using Spark, since this was two operating system versions away from VoiceOver
AppleScript support.
AppleScript follows below my sig after "Cut Here". Command R will run it. You
can save it as either an Application or an AppleScript. You might also want to
add a "delay 0.5" argument before the "say" command if you want to make sure
VoiceOver stops speaking previous material before the time announcement. (This
used to be necessary.)
HTH. Cheers,
Esther
----Cut Here---
(*
Say Time Script
October 12, 2008
*)
say "The current time is " & getTimeInHoursAndMinutes()
on getTimeInHoursAndMinutes()
-- Get the "hour"
set timeStr to time string of (current date)
set Pos to offset of ":" in timeStr
set theHour to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
-- Get the "minute"
set Pos to offset of ":" in timeStr
set theMin to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
--Get "AM or PM"
set Pos to offset of " " in timeStr
set theSfx to characters (Pos + 1) through end of timeStr as string
return (theHour & ":" & theMin & " " & theSfx) as string
end getTimeInHoursAndMinutes
On Aug 18, 2011, at 1216, Alex Hall wrote:
> No, but mine does the same thing (10.7.1). I have checked "allow
> voiceOver to be controlled by Apple scripts".
>
> On 8/18/11, craig J Dunlop <[email protected]> wrote:
>> I changed my time to be 24 hour but the hot key I setup reads 12 hour time
>> using lion.
>> anyone have any thoughts?
>>
--
You received this message because you are subscribed to the Google Groups
"MacVisionaries" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/macvisionaries?hl=en.