From b1ba45ab906c14a50c7a2b099624b7f4b29dce2c Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Mon, 10 Jun 2024 23:29:04 -0400 Subject: [PATCH] [1805] Update Prototypes --- hotkey/windows.py | 5 ++++- l10n.py | 1 - monitor.py | 4 +++- prefs.py | 5 ++++- stats.py | 12 ++++++------ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/hotkey/windows.py b/hotkey/windows.py index 188c89e9..671df1e8 100644 --- a/hotkey/windows.py +++ b/hotkey/windows.py @@ -8,7 +8,7 @@ import sys import threading import tkinter as tk import winsound -from ctypes.wintypes import DWORD, LONG, MSG, ULONG, WORD +from ctypes.wintypes import DWORD, LONG, MSG, ULONG, WORD, HWND, BOOL, UINT import pywintypes import win32api import win32gui @@ -21,6 +21,8 @@ assert sys.platform == 'win32' logger = get_main_logger() UnregisterHotKey = ctypes.windll.user32.UnregisterHotKey # TODO: Coming Soon +UnregisterHotKey.argtypes = [HWND, ctypes.c_int] +UnregisterHotKey.restype = BOOL MOD_ALT = 0x0001 MOD_CONTROL = 0x0002 @@ -138,6 +140,7 @@ class INPUT(ctypes.Structure): SendInput = ctypes.windll.user32.SendInput SendInput.argtypes = [ctypes.c_uint, ctypes.POINTER(INPUT), ctypes.c_int] +SendInput.restype = UINT INPUT_MOUSE = 0 INPUT_KEYBOARD = 1 diff --git a/l10n.py b/l10n.py index 8613244f..29c18f75 100755 --- a/l10n.py +++ b/l10n.py @@ -50,7 +50,6 @@ if sys.platform == 'win32': GetUserPreferredUILanguages.argtypes = [ DWORD, ctypes.POINTER(ctypes.c_ulong), LPCVOID, ctypes.POINTER(ctypes.c_ulong) ] - GetUserPreferredUILanguages.restype = BOOL LOCALE_NAME_USER_DEFAULT = None diff --git a/monitor.py b/monitor.py index ba1a4d39..5a971c69 100644 --- a/monitor.py +++ b/monitor.py @@ -36,7 +36,7 @@ MAX_FCMATERIALS_DISCREPANCY = 5 # Timestamp difference in seconds if sys.platform == 'win32': import ctypes - from ctypes.wintypes import BOOL, HWND, LPARAM + from ctypes.wintypes import BOOL, HWND, LPARAM, HANDLE import win32gui from watchdog.events import FileSystemEventHandler, FileSystemEvent @@ -45,6 +45,8 @@ if sys.platform == 'win32': EnumWindowsProc = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM) CloseHandle = ctypes.windll.kernel32.CloseHandle + CloseHandle.argtypes = [HANDLE] + CloseHandle.restype = BOOL GetProcessHandleFromHwnd = ctypes.windll.oleacc.GetProcessHandleFromHwnd else: diff --git a/prefs.py b/prefs.py index e7ccef18..89e107fb 100644 --- a/prefs.py +++ b/prefs.py @@ -188,7 +188,7 @@ class AutoInc(contextlib.AbstractContextManager): if sys.platform == 'win32': import ctypes import winreg - from ctypes.wintypes import HINSTANCE, LPCWSTR, LPWSTR, MAX_PATH, POINT, RECT, SIZE, UINT + from ctypes.wintypes import HINSTANCE, LPCWSTR, LPWSTR, MAX_PATH, POINT, RECT, SIZE, UINT, BOOL import win32gui is_wine = False try: @@ -204,6 +204,8 @@ if sys.platform == 'win32': if not is_wine: try: CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition + CalculatePopupWindowPosition.argtypes = [POINT, SIZE, UINT, RECT, RECT] + CalculatePopupWindowPosition.restype = BOOL except AttributeError as e: logger.error( @@ -225,6 +227,7 @@ if sys.platform == 'win32': LoadString = ctypes.windll.user32.LoadStringW LoadString.argtypes = [HINSTANCE, UINT, LPWSTR, ctypes.c_int] + LoadString.restype = ctypes.c_int class PreferencesDialog(tk.Toplevel): diff --git a/stats.py b/stats.py index 965b7fc8..b8a6531a 100644 --- a/stats.py +++ b/stats.py @@ -25,7 +25,7 @@ logger = EDMCLogging.get_main_logger() if sys.platform == 'win32': import ctypes - from ctypes.wintypes import POINT, RECT, SIZE, UINT + from ctypes.wintypes import POINT, RECT, SIZE, UINT, BOOL import win32gui try: @@ -33,6 +33,7 @@ if sys.platform == 'win32': CalculatePopupWindowPosition.argtypes = [ ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT) ] + CalculatePopupWindowPosition.restype = BOOL except Exception: # Not supported under Wine 4.0 CalculatePopupWindowPosition = None # type: ignore @@ -240,7 +241,7 @@ def ships(companion_data: dict[str, Any]) -> list[ShipRet]: """ Return a list of 5 tuples of ship information. - :param data: [description] + :param companion_data: [description] :return: A 5 tuple of strings containing: Ship ID, Ship Type Name (internal), Ship Name, System, Station, and Value """ ships: list[dict[str, Any]] = companion.listify(cast(list, companion_data.get('ships'))) @@ -250,16 +251,15 @@ def ships(companion_data: dict[str, Any]) -> list[ShipRet]: ships.insert(0, ships.pop(current)) # Put current ship first if not companion_data['commander'].get('docked'): - out: list[ShipRet] = [] # Set current system, not last docked - out.append(ShipRet( + out: list[ShipRet] = [ShipRet( id=str(ships[0]['id']), type=ship_name_map.get(ships[0]['name'].lower(), ships[0]['name']), name=str(ships[0].get('shipName', '')), system=companion_data['lastSystem']['name'], station='', value=str(ships[0]['value']['total']) - )) + )] out.extend( ShipRet( id=str(ship['id']), @@ -299,7 +299,7 @@ def export_ships(companion_data: dict[str, Any], filename: AnyStr) -> None: h.writerow(list(thing)) -class StatsDialog(): +class StatsDialog: """Status dialog containing all of the current cmdr's stats.""" def __init__(self, parent: tk.Tk, status: tk.Label) -> None: