Quote:
I use the first script to start the second script after the game is running, will this work correctly to "start my script after the game"
There is a better way: The hook can be dynamically installed or removed indirectly by means of commands that load it conditionally. For example, in this script the hook is removed when hotkeys are suspended by put back when they are resumed:
$^!#s::return ; Hook hotkey that does nothing.
#z::suspend
Quote:
I guess the question comes down to whether AutoHotKey is run once for each script, or once for all running scripts
Every script gets its own instance.
Quote:
With this new AutoHotKey, my test script is simple. I'm going to call "MouseClick, RIGHT". My assumption is the new EXE is going to automatically strip the injected bit for me, right?
I only provided those three scripts for testing purposes. Beyond that simple test, they serve no purpose whatsoever. In other words, it is enough to run a single script with the modified EXE. As long as the mouse/keyboard hooks are installed by it, the bit will be changed.
Quote:
Then I started the third script and the tooltips were staying ontop nicely. This meant some sort of hooking was happening successfully there.
I don't think the tooltips being on top has anything to do with the hooks. It's probably just a coincidence.
Quote:
The downside, was that the simulated mouse movements no longer updated either overall OR physical, when it was updating both before opening and after closing the game. So, as you suggested, it must be something other than the injected bit being checked, because even the "overall" time kept climbing until I physically moved the mouse. Any ideas here?
That's interesting. The "overall" time is gathered directly from an API function called GetLastInputInfo(). It seems as though the game is intentionally or unintentionally blocking that function from reporting the correct time. Perhaps the game is using some form of BlockInput?
Quote:
Something else odd that happened, when I closed the game, it said that the third script could not hook the keyboard and some functionality would not work in the script.
That could be a sign that the game is doing something to explicitly disable other programs or other hooks. If we could figure out how it does this, that might help our understanding.
Quote:
It seems to cause the third script to gain video presidence despite the game hooking things like GetForegroundWindow I think.
I don't know if that's relevant or possible, but if it is, I know basically nothing about it.
Quote:
None the less, you might be right in that injected flag is not the data being compared for physical/virtual input. Any other ideas?
No... perhaps there is some game designing trade secret that has not been publicized.
Quote:
What I was thinking might be happening is game.exe is using HanDes.dll to globally hook the input, and when the hook is called from game.exe, HanDes.dll adds a flag or changes one on the mouse data which it checks for in the game further along.
Even if this were true, it doesn't explain how the game knows in the first place which events to call the hook with and which to ignore.
Quote:
if AutoHotKey hooks first, strips the injected bit, passes on to HanDes.dll, then it should manipulate the data as it would a physically moved mouse. I'm lost, I don't know where they are comparing data between physical and generated events now that the injected bit is stripped.
Do you know of any other potential spots?
If the AHK hook cannot be installed after the game has started, that might explain it. It's also possible that the game is installing a hook sometime after it starts, which would give its hook precedence. But more likely, it's none of the above and the game is doing something else entirely.
Quote:
If you log the flags of the mouse event before and after the strip occurs
Since the three test scripts were not intended for use with a game, I don't think this will help. But let me know if you want to pursue it.
Quote:
What we're hoping to see here is after after we strip our injected bit off and it's passed into the game hook, we want to see what the flags are again after the game hook, and compare the flag values.
There would be no reason for the game to change the flags if it can already differentiate between artificial and physical input.