def get_control_panel_applets(): if utils.platform_windows_vista() or utils.platform_windows_7(): from enso.contrib.open.platform.win32 import control_panel_vista_win7 return control_panel_vista_win7.get_control_panel_applets() else: from enso.contrib.open.platform.win32 import control_panel_2000_xp return control_panel_2000_xp.get_control_panel_applets()
win_shortcuts, ) from enso.contrib.open.shortcuts import * # IGNORE:W0401 from enso.utils.decorators import (timed_execution, timed, synchronized, debounce) from enso.utils import suppress from enso.contrib.scriptotron.ensoapi import EnsoApi from enso.contrib.open.platform.win32.decorators import initialize_pythoncom from enso.system import dirwalk try: import regex as re except ImportError: import re if utils.platform_windows_vista() or utils.platform_windows_7(): from enso.contrib.open.platform.win32 import control_panel_vista_win7 as control_panel else: from enso.contrib.open.platform.win32 import control_panel_2000_xp as control_panel __updated__ = "2019-05-21" logger = logging.getLogger(__name__) REPORT_UNRESOLVABLE_TARGETS = False # Debouncing time of shortcuts refreshes in seconds SHORTCUTS_REFRESH_DEBOUNCE_TIME = 4 EXECUTABLE_EXTS = ['.exe', '.com', '.cmd', '.bat', '.py', '.pyw'] EXECUTABLE_EXTS.extend([
def get_control_panel_applets(): if utils.platform_windows_vista() or utils.platform_windows_7(): from enso.contrib.open.platform.win32 import control_panel_win7 return control_panel_win7.get_control_panel_applets() control_panel_applets = [] cpi = ControlPanelInfo() # Read disabled ("don't load") control-panels from registry # Note: Control-panel applets can be disabled using TweakUI cpl_disabled_panels = [] for cplfile, _, _ in registry.walk_values(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\don't load", valuetypes = (win32con.REG_SZ,)): cpl_disabled_panels.append(cplfile.lower()) # List control-panel applets from system directory cpl_files = [cpl for cpl in glob.iglob(os.path.join(os.path.expandvars("${WINDIR}"), "system32", "*.cpl")) if os.path.basename(cpl).lower() not in cpl_disabled_panels] # Add control-panel applets from custom locations, read from registry for _, cplfile, _ in registry.walk_values( win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls", valuetypes = (win32con.REG_EXPAND_SZ, win32con.REG_SZ), autoexpand = True): if not os.path.isfile(cplfile): continue if os.path.basename(cplfile).lower() in cpl_disabled_panels: continue cpl_files.append(cplfile) # Read descriptions of control-panel applets from the .cpl files directly for cplfile in cpl_files: for file, name, desc, index in cpi.get_cplinfo(cplfile): name = unicodedata.normalize('NFKD', name).encode('ascii', 'ignore') name = name.lower() #name = xml_escape(name) control_panel_applets.append( shortcuts.Shortcut( name + " (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL \"%s\",@%d" % (cplfile, index) )) del cpi # Extend control-panel applets list with few useful shortcuts that can't be # reached from the control-panel directly control_panel_applets.extend([ shortcuts.Shortcut( u"control panel", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL"), shortcuts.Shortcut( u"about microsoft windows (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,ShellAboutW "), shortcuts.Shortcut( u"safely remove hardware", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL HotPlug.dll"), shortcuts.Shortcut( u"unplug or eject hardware", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL HotPlug.dll"), shortcuts.Shortcut( u"device manager (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, #"rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1" "rundll32.exe devmgr.dll DeviceManager_Execute"), shortcuts.Shortcut( u"disk management (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "diskmgmt.msc"), shortcuts.Shortcut( u"scheduled tasks (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "control.exe schedtasks"), shortcuts.Shortcut( u"scanners and cameras (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "control.exe sticpl.cpl"), shortcuts.Shortcut( u"removable storage (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "ntmsmgr.msc"), shortcuts.Shortcut( u"performance monitor (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "perfmon.msc"), shortcuts.Shortcut( u"private character editor (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "eudcedit.msc"), ]) return control_panel_applets