Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

登陆后卡住:不断重复”左上角发现派蒙,表示不在打开的地图界面,获取地图比例失败“,且无法操作游戏“ #20

Open
tignioj opened this issue Nov 15, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@tignioj
Copy link
Owner

tignioj commented Nov 15, 2024

复现步骤:

  1. 先手动启动游戏
  2. 启动MiniMapServer,点击“一键运行所有实例”,此时会强制关掉手动启动的实例
  3. 首个实例成功登陆后(官服),程序不断循环输出:”左上角发现派蒙,表示不在打开的地图界面,获取地图比例失败“,且无法操作游戏。(没有开启BGI)

现象如下:

  1. 此时鼠标无法转动视角(即拖动鼠标,游戏视角没有任何变化),但是可以按下 鼠标左键、鼠标右键、鼠标中间,游戏内有对应的反应。
  2. 键盘几乎所有按键(除了win按键和大写锁定按键)失效,wsad、空格、Ctrl、shift、ESC、Enter、F1、inert、delete均无效,大小写切换正常,切换大小写后其余按键仍然失效。
  3. 按下win按键时,正常弹出windows菜单,此时游戏被windows菜单覆盖,再次按下win键收起菜单,此时游戏重新置于前台,不再卡住。

疑惑

  1. 既然可以登录成功,表明起初键盘是可以控制游戏的,因为登录需要点击一系列按钮,为何登陆后,键盘、鼠标突然失效?
  2. 键盘失效期间,鼠标可以正常重击、普通攻击、冲刺、长按中间视野、但是偏偏无法转动视角?为何双击win按键后又恢复正常?
@tignioj tignioj changed the title 登陆后卡住:不断重复”左上角发现派蒙,表示不再在地图界面,获取地图比例失败“ 登陆后卡住:不断重复”左上角发现派蒙,表示不在打开的地图界面,获取地图比例失败“,且无法操作游戏“ Nov 15, 2024
@tignioj tignioj added the bug Something isn't working label Nov 15, 2024
@tignioj
Copy link
Owner Author

tignioj commented Nov 17, 2024

经过测试,和shift无关,此更新无法解决卡住问题 42e6b00

@tignioj
Copy link
Owner Author

tignioj commented Nov 26, 2024

初步推测是游戏窗口名称与启动器名称冲突相关。

image

使用windowscapture3.py 运行发现截图的是启动器的截图而非游戏截图
image

检查窗口代码

def list_all_windows():
    def callback(hwnd, extra):
        if win32gui.IsWindowVisible(hwnd):
            window_title = win32gui.GetWindowText(hwnd)
            class_name = win32gui.GetClassName(hwnd)
            if window_title:  # 只显示有标题的窗口
                print(f"窗口标题: {window_title}, 窗口类名: {class_name}")

    win32gui.EnumWindows(callback, None)

输出如下

窗口标题: YuanShen.exe 属性, 窗口类名: #32770
窗口标题: 原神, 窗口类名: Qt51517QWindowIcon
窗口标题: 原神, 窗口类名: UnityWndClass
...

在原来的截图代码中,激活窗口使用的是

    def activate_window(self):
        """
        将窗口置于前台
        :return:
        """
        self.hwnd = win32gui.FindWindow(None, self.window_name)
        if not self.hwnd:
            raise WindowsNotFoundException(self.window_name)

        if self.hwnd is not None:
            win32gui.SetForegroundWindow(self.hwnd)

修改为

    def activate_window(self):
        """
        将窗口置于前台
        :return:
        """
        self.hwnd = win32gui.FindWindow("UnityWndClass", self.window_name)
        if not self.hwnd:
            raise WindowsNotFoundException(self.window_name)

        if self.hwnd is not None:
            win32gui.SetForegroundWindow(self.hwnd)

此时截图器成功截图游戏界面

@tignioj
Copy link
Owner Author

tignioj commented Nov 27, 2024

LoginControlelr中快速复现

先手动打开游戏,然后执行

if __name__ == '__main__':
    from myutils.os_utils import kill_game
    kill_game()
    login = LoginController()
    login.open_game()

点击游戏进入后,复现键盘失灵BUG

@tignioj
Copy link
Owner Author

tignioj commented Nov 28, 2024

把LoginController中的os.startfile改为Popen修复 75eecb0

        subprocess.Popen([game_path], shell=True)
        # os.startfile(game_path)

@tignioj tignioj closed this as completed Nov 28, 2024
@tignioj
Copy link
Owner Author

tignioj commented Dec 2, 2024

v0.0.7-update2仍旧遇到同样的卡住问题,原来的复现方式无法再次复现。从官服1切换到官服2时偶然复现

@tignioj tignioj reopened this Dec 2, 2024
@ligodamn
Copy link

ligodamn commented Dec 7, 2024

注释掉

增加激活频率

    time.sleep(10)
    start_wait = time.time()
    while not capture.is_active() and time.time() - start_wait < 120 and not self.stop_listen:
        try:
            capture.activate_window()
        except Exception as e:
            self.logger.debug(e.args)
            self.logger.debug(f'正在打开游戏中, 剩余等待时间{120-(time.time() - start_wait)}')
        time.sleep(2)

修改为

    #time.sleep(10)
    start_wait = time.time()
    while not capture.is_active() and time.time() - start_wait < 120 and not self.stop_listen:
        try:
            capture.activate_window()
        except Exception as e:
            self.logger.debug(e.args)
            self.logger.debug(f'正在打开游戏中, 剩余等待时间{120-(time.time() - start_wait)}')
        time.sleep(0.5)

可以稳定复现


在激活窗口操作前加入延迟time.sleep(10)后问题消失

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants