【Pyhton】如何用python调用Windows属性窗口

代码:
import time
import ctypes
import ctypes.wintypes

SEE_MASK_NOCLOSEPROCESS = 0x00000040
SEE_MASK_INVOKEIDLIST = 0x0000000C

class SHELLEXECUTEINFO(ctypes.Structure):
_fields_ = (
("cbSize",ctypes.wintypes.DWORD),
("fMask",ctypes.c_ulong),
("hwnd",ctypes.wintypes.HANDLE),
("lpVerb",ctypes.c_char_p),
("lpFile",ctypes.c_char_p),
("lpParameters",ctypes.c_char_p),
("lpDirectory",ctypes.c_char_p),
("nShow",ctypes.c_int),
("hInstApp",ctypes.wintypes.HINSTANCE),
("lpIDList",ctypes.c_void_p),
("lpClass",ctypes.c_char_p),
("hKeyClass",ctypes.wintypes.HKEY),
("dwHotKey",ctypes.wintypes.DWORD),
("hIconOrMonitor",ctypes.wintypes.HANDLE),
("hProcess",ctypes.wintypes.HANDLE),
)

ShellExecuteEx = ctypes.windll.shell32.ShellExecuteEx
ShellExecuteEx.restype = ctypes.wintypes.BOOL

sei = SHELLEXECUTEINFO()
sei.cbSize = ctypes.sizeof(sei)
sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_INVOKEIDLIST
sei.lpVerb = "properties".encode('utf-8')
sei.lpFile = r'I:\1.txt'.encode('utf-8')#这里填上你要查看的文件路径,由于python环境不同我这边必须得加上.encode('utf-8'),如有异常的话删除后试试。sei.nShow = 1
ShellExecuteEx(ctypes.byref(sei))
time.sleep(5)


我这边的报错TypeError: bytes or integer address expected instead of str instance
posted @ 2022-03-11 16:48  瑞尔小透  阅读(516)  评论(0编辑  收藏  举报
Live2D