简体   繁体   English

是否有可能以编程方式防止游戏在其 window 失去焦点时暂停?

[英]Is it possible to programmatically prevent a game from pausing when its window loses focus?

I'm playing Skyrim in windowed mode and I am trying to create a bot for this game for personal use.我在窗口模式下玩 Skyrim,我正在尝试为这个游戏创建一个供个人使用的机器人。 I would like to have the bot play the game in the background, while I do other things, the only problem is that the game window pauses when it loses focus.我想让机器人在后台玩游戏,而我做其他事情,唯一的问题是游戏 window 在失去焦点时暂停。 Is there a way to make the Skyrim process think that it still has the focus, so it continues to run while I do something else on another window?有没有办法让 Skyrim 进程认为它仍然有焦点,所以当我在另一个 window 上做其他事情时它继续运行? I'm not a windows programming expert but would this be possible if I could somehow intercept the message that says unfocused or minimized to the process, and thus let the process think its still focused?我不是 windows 编程专家,但如果我能以某种方式截获对流程不专心或最小化的消息,从而让流程认为它仍然专注,这是否可能?

It's possible.这是可能的。 You need to find the mechanism through which the game checks whether it's in the foreground then trick it into thinking the switch has not occurred.你需要找到游戏检查它是否在前台然后欺骗它认为切换没有发生的机制。 This will require a certain amount of reverse engineering on your part.这将需要您进行一定数量的逆向工程。 There are many different ways that this checking can actually be done by the game.游戏实际上可以通过许多不同的方式来完成此检查。

You can try to play with hooking one of the following messages/functions: WM_KILLFOCUS , WM_ACTIVATE , GetForegroundWindow .您可以尝试挂接以下消息/函数之一: WM_KILLFOCUSWM_ACTIVATEGetForegroundWindow On the other hand, the game might be doing something funky with DirectX.另一方面,游戏可能会使用 DirectX 做一些时髦的事情。 I don't have much experience there.我在那里没有太多经验。

To re-iterate, to do this properly you are really going to have to find out exactly how the game does the checking (and then subvert that).重申一下,要正确地做到这一点,您真的必须准确地找出游戏是如何进行检查的(然后颠覆它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在窗口失焦或调整大小时停止暂停OpenGL? - How to stop OpenGL from pausing when the window is out of focus or resizing? 将窗口保持在前景中(即使它失去焦点) - Keep window in foreground (even if it loses focus) 当表单失去焦点时处理睡眠 - Process sleep when form loses focus 双击时暂停批处理文件,但从控制台窗口运行时不暂停? - Pausing a batch file when double-clicked but not when run from a console window? 是否可以从bat脚本确定具有焦点的窗口/应用程序? - Is it possible to determine the window/application with focus from a bat script? 新创建的模式窗口在Windows Vista中失去焦点并变得无法使用 - Newly created modal window loses focus and become inacessible in Windows Vista (Javascript) 如何将焦点返回到 OPENER 窗口(不更改其 URL) - 从其(子)弹出窗口? - How (Javascript) return focus to the OPENER window (without changing its URL) - from its (child) popup? 当程序失去焦点时,WH_FOREGROUNDIDLE停止 - WH_FOREGROUNDIDLE stops when program loses focus Qt 应用程序失去焦点时系统托盘上下文菜单仍然存在 - Qt system tray context menu remains when app loses focus 从我的窗口释放焦点 - Release the focus from my window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM