mirror of
https://github.com/derrod/legendary.git
synced 2024-09-28 07:22:08 +12:00
Open CMD when exe is double-clicked
This opens up CMD if - the exe file was double-clicked - no arguments are provided - we're on Windows
This commit is contained in:
parent
fc73c1d4bf
commit
496bae1fe4
2 changed files with 17 additions and 0 deletions
|
@ -28,6 +28,7 @@ from legendary.utils.env import is_windows_mac_or_pyi
|
|||
from legendary.utils.eos import add_registry_entries, query_registry_entries, remove_registry_entries
|
||||
from legendary.utils.lfs import validate_files, clean_filename
|
||||
from legendary.utils.selective_dl import get_sdl_appname
|
||||
from legendary.utils.windows_helpers import double_clicked
|
||||
from legendary.utils.wine_helpers import read_registry, get_shell_folders
|
||||
|
||||
# todo custom formatter for cli logger (clean info, highlighted error/warning)
|
||||
|
@ -2894,6 +2895,8 @@ def main():
|
|||
continue
|
||||
print(f'\nCommand: {choice}')
|
||||
print(subparser.format_help())
|
||||
elif os.name == 'nt' and double_clicked():
|
||||
subprocess.run(['cmd', '/K', 'echo>nul'])
|
||||
return
|
||||
|
||||
cli = LegendaryCLI(override_config=args.config_file, api_timeout=args.api_timeout)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
import winreg
|
||||
import ctypes
|
||||
|
||||
_logger = logging.getLogger('WindowsHelpers')
|
||||
|
||||
|
@ -80,3 +81,16 @@ def set_registry_value(hive, key, value, data, reg_type=winreg.REG_SZ, use_32bit
|
|||
except Exception as e:
|
||||
_logger.debug(f'Setting "{key}":"{value}" to "{data}" failed with {repr(e)}')
|
||||
winreg.CloseKey(k)
|
||||
|
||||
|
||||
def double_clicked() -> bool:
|
||||
# Thanks https://stackoverflow.com/a/55476145
|
||||
|
||||
# Load kernel32.dll
|
||||
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
|
||||
# Create an array to store the processes in. This doesn't actually need to
|
||||
# be large enough to store the whole process list since GetConsoleProcessList()
|
||||
# just returns the number of processes if the array is too small.
|
||||
process_array = (ctypes.c_uint * 1)()
|
||||
num_processes = kernel32.GetConsoleProcessList(process_array, 1)
|
||||
return num_processes < 3
|
||||
|
|
Loading…
Reference in a new issue