Skip to content

Commit cf580cb

Browse files
authored
Merge 389287a into 861c690
2 parents 861c690 + 389287a commit cf580cb

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

source/globalCommands.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import globalVars
3434
from logHandler import log
3535
import gui
36+
import systemUtils
3637
import wx
3738
import config
3839
from config.configFlags import TetherTo
@@ -263,7 +264,7 @@ def script_reportCurrentSelection(self,gesture):
263264
speech.speakMessage(_("No selection"))
264265
else:
265266
speech.speakTextSelected(info.text)
266-
267+
267268
@script(
268269
# Translators: Input help mode message for report date and time command.
269270
description=_("If pressed once, reports the current time. If pressed twice, reports the current date"),
@@ -272,7 +273,10 @@ def script_reportCurrentSelection(self,gesture):
272273
)
273274
def script_dateTime(self,gesture):
274275
if scriptHandler.getLastScriptRepeatCount()==0:
275-
text=winKernel.GetTimeFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.TIME_NOSECONDS, None, None)
276+
if systemUtils._isSystemClockSecondsVisible():
277+
text = winKernel.GetTimeFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT, None, None, None)
278+
else:
279+
text = winKernel.GetTimeFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.TIME_NOSECONDS, None, None)
276280
else:
277281
text=winKernel.GetDateFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.DATE_LONGDATE, None, None)
278282
ui.message(text)
@@ -2747,7 +2751,6 @@ def script_log_markStartThenCopy(self, gesture):
27472751
)
27482752
@gui.blockAction.when(gui.blockAction.Context.SECURE_MODE)
27492753
def script_openUserConfigurationDirectory(self, gesture):
2750-
import systemUtils
27512754
systemUtils.openUserConfigurationDirectory()
27522755

27532756
@script(

source/systemUtils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
windll,
1414
)
1515
import winKernel
16+
import winreg
1617
import shellapi
1718
import winUser
1819
import functools
@@ -189,3 +190,22 @@ def _displayTextFileWorkaround(file: str) -> None:
189190
# Since this may be a bug in Python 3.7's os.startfile, or the underlying Win32 function, it may be
190191
# possible to deprecate this workaround after a Python upgrade.
191192
startfile(file, operation="edit")
193+
194+
def _isSystemClockSecondsVisible() -> bool:
195+
"""
196+
Query the value of 'ShowSecondsInSystemClock' DWORD32 value in the Windows registry under
197+
the path HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced.
198+
If the value is 1, return True, if the value is 0 or the key does not exist, return False.
199+
200+
@return: True if the 'ShowSecondsInSystemClock' value is 1, False otherwise.
201+
"""
202+
registry_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
203+
value_name = "ShowSecondsInSystemClock"
204+
try:
205+
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, registry_path) as key:
206+
value, value_type = winreg.QueryValueEx(key, value_name)
207+
return value == 1 and value_type == winreg.REG_DWORD
208+
except FileNotFoundError:
209+
return False
210+
except OSError:
211+
return False

0 commit comments

Comments
 (0)