Starry-Wind / StarRailAssistant

崩坏:星穹铁道自动化 | 崩坏:星穹铁道自动锄大地 | 崩坏:星穹铁道锄大地 | 自动锄大地 | 基于模拟按键
GNU General Public License v3.0
2.81k stars 236 forks source link

[Bug] pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available') #242

Closed QuartzKun closed 1 year ago

QuartzKun commented 1 year ago

问题描述

选择起始地图后自动切换窗口时出错(/tools/switch_window.py) 参考Stack Overflow: win32gui.SetActiveWindow() ERROR : The specified procedure could not be found能够解决

预期行为

直接切换至游戏窗口内开始寻路

实际行为

报错,鼠标指针被锁定至屏幕中央,任务栏中游戏图标高亮

截图或录屏

image

自动锄大地脚本版本

20230520192933

星穹铁道区服

国服

日志

00:43:13 - DEBUG | map.read_maps:44 - 3.1 - ['map_1-1_1.json', 'map_1-2_1.json', 'map_1-2_2.json', 'map_1-2_3.json', 'map_1-2_4.json', 'map_1-3_1.json', 'map_1-3_2.json', 'map_1-3_3.json', 'map_1-3_4.json', 'map_2-1_1.json', 'map_2-1_2.json', 'map_2-2_1.json', 'map_2-2_2.json', 'map_2-3_1.json', 'map_2-3_2.json', 'map_2-3_3.json', 'map_2-3_4.json', 'map_2-3_5.json', 'map_2-4_1.json', 'map_2-4_2.json', 'map_2-5_1.json', 'map_2-5_2.json', 'map_2-5_3.json', 'map_2-5_4.json', 'map_2-6_1.json', 'map_2-6_2.json', 'map_2-7_1.json', 'map_2-7_2.json', 'map_2-7_3.json', 'map_3-1_1.json', 'map_3-1_2.json', 'map_3-1_3.json', 'map_3-1_4.json', 'map_3-2_1.json', 'map_3-2_2.json', 'map_3-2_3.json', 'map_3-2_4.json', 'map_3-2_5.json', 'map_3-3_1.json', 'map_3-3_2.json', 'map_3-3_3.json', 'map_3-3_4.json', 'map_3-4_1.json', 'map_3-4_2.json', 'map_3-4_3.json', 'map_3-4_4.json', 'map_3-4_5.json', 'map_3-4_6.json'] 00:43:13 - DEBUG | map.read_maps:45 - 3.1 - {'1': {'1_1': '基座舱段-1', '2_1': '收容舱段-1', '2_2': '收容舱段-2', '2_3': '收容舱段-2', '2_4': '收容舱段-3', '3_1': '支援舱段-1', '3_2': '支援舱段-2', '3_3': '支援舱段-3', '3_4': '支援舱段-4'}, '2': {'1_1': '城郊雪原-1', '1_2': '城郊雪原-2', '2_1': '边缘道路-1', '2_2': '边缘道路-2', '3_1': '残响回廊-1', '3_2': '残响回廊-2', '3_3': '残响回廊-3', '3_4': '残响回廊-4', '3_5': '残响回廊-5', '4_1': '永冬岭-1', '4_2': '永冬岭-2', '5_1': '大矿区-1', '5_2': '大矿区-2', '5_3': '大矿区-3', '5_4': '大矿区-4', '6_1': '铆钉镇-1', '6_2': '铆钉镇-2', '7_1': '机器聚落-1', '7_2': '机器聚落-2', '7_3': '机器聚落-3'}, '3': {'1_1': '流云渡-1', '1_2': '流云渡-2', '1_3': '流云渡-3', '1_4': '流云渡-4', '2_1': '迥星港-1', '2_2': '迥星港-2', '2_3': '迥星港-3', '2_4': '迥星港-4', '2_5': '迥星港-5', '3_1': '太卜司-1', '3_2': '太卜司-2', '3_3': '太卜司-3', '3_4': '太卜司-4', '4_1': '工造司-1', '4_2': '工造司-2', '4_3': '工造司-3', '4_4': '工造司-4', '4_5': '工造司-5', '4_6': '工造司-6'}} 00:43:16 - INFO | Honkai_Star_Rail.main:42 - 3.1 - 脚本将自动切换至游戏窗口,请保持游戏窗口激活 00:43:16 - ERROR | Honkai_Star_Rail.:151 - 3.1 - Traceback (most recent call last): File "C:\Users\User\Downloads\Honkai-Star-Rail-1.1.7\Honkai_Star_Rail.py", line 139, in main() File "C:\Users\User\Downloads\Honkai-Star-Rail-1.1.7\Honkai_Star_Rail.py", line 44, in main switch_window() File "C:\Users\User\Downloads\Honkai-Star-Rail-1.1.7\tools\switch_window.py", line 12, in switch_window win32gui.SetForegroundWindow(hwnd) pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available')

Starry-Wind commented 1 year ago

已经回退版本,可正常使用

LuoRenMu commented 1 year ago

此问题应该是我删除

win32com.client.Dispatch("WScript.Shell")
shell.SendKeys('%')

所导致的