pywintypes.error: (87, 'OpenProcess', '参数错误。')
siyu1992 opened this issue · comments
UP主您好,想请教一个问题,我在运行train.py的时候,在GetHP这个脚本中,实例化Hp_getter()这个类的时候遇到了问题,
File "D:\python_workspace\git\DQN_HollowKnight-main\Tool\GetHP.py", line 30, in init
self.process_handle = win32api.OpenProcess(0x1F0FFF, False, pid)
pywintypes.error: (87, 'OpenProcess', '参数错误。')
我打印了hd = win32gui.FindWindow(None, "Hollow Knight")
pid = win32process.GetWindowThreadProcessId(hd)[1] 这两行代码的输出,发现pid获取出来是负数(如:-1499715320),我的系统是64位的win10,请问您是否遇到过类似的问题,有无解决方案呢,谢谢
你可以尝试输出hd = win32gui.FindWindow(None, "Hollow Knight"),查看它是否正确。
这个函数根据窗口名称来确定句柄,如果你使用的不是steam版游戏,也许窗口名不一样。
可以尝试将“Hollow Knight” 替换为你的游戏显示的窗口名。
原来如此,我用stream版本的试试,谢谢
…------------------ 原始邮件 ------------------
发件人: "ailec0623/DQN_HollowKnight" ***@***.***>;
发送时间: 2021年4月8日(星期四) 凌晨0:23
***@***.***>;
***@***.******@***.***>;
主题: Re: [ailec0623/DQN_HollowKnight] pywintypes.error: (87, 'OpenProcess', '参数错误。') (#1)
你可以尝试输出hd = win32gui.FindWindow(None, "Hollow Knight"),查看它是否正确。
这个函数根据窗口名称来确定句柄,如果你使用的不是steam版游戏,也许窗口名不一样。
可以尝试将“Hollow Knight” 替换为你的游戏显示的窗口名。
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.