Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Is this possible to do with AHK (keyboard hook)


  • Please log in to reply
6 replies to this topic
Physical
  • Guests
  • Last active:
  • Joined: --
I have not scripted in AHK before but i have been looking in the help files and trying to read about the functions and read the forum as much as i can to answer this question. I havent yet found a definate answer tho.

Objective - Make a macro that uses a keyboard hook (or any workable method) to send keystrokes to a game using gameguard. The keystrokes have to be low lvl and appear to be coming directly from the keyboard.

AHK doesnt use low lvl programming i know so in itself it cant do it. However, what if the dll call function is used to load a low lvl keyboard hook dll, would it then be possible? I know AHK has a keyboard hook built into it but i do not know if it is able to do it either.

First i want to know if its possible. If it is then could soemone please point me in the right direction as for how to accomplish it or tell me if the idea i have now will work provided i code it properly. Thankyou

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
there is quite a bit on this forum regarding gameguard. Also, do you have a dll in mind that has low level keyboard capability? if there exists such a dll, we can help you learn to use it.

Physical
  • Guests
  • Last active:
  • Joined: --
yes i have a file from another macro that did work but the trial expired and i dont want to pay 40 bucks to continue using this macro. Its got a dll file for doing keyboard hooks. By using this dll file in conjunction with an autohotkey script it would be able to send keys to the game just like the macro did previously?

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
Can you tell us what it is? To use a DLL, you need the documentation that tells you what function to call in the DLL and what arguments it wants. Without that, it's worthless. You may be able to use something like reshacker or PEexplorer to look at the dll and see what functions there are.

$40 is pretty cheap, considering how much time you'll be spending figuring this out.

Physical
  • Guests
  • Last active:
  • Joined: --
well atm i lost my job so i have plenty of time :) but no money :( I dont have any documentation for the dll i would have to get something to let me look at the functions like you said. I have no way to host the file for someone to download either :( sorry. Plus i would rather figure this out first cuz as soon as something becomes popular gameguard finds a way to block it.

The only other thing i was thinking of trying if i found out AHK was incapable of doing it, was to make a program in ASM (which i would have to learn :/) thats only function is to send keystrokes.

Zippo()
  • Guests
  • Last active:
  • Joined: --
Have you even tried sending keystrokes using AHK to your game yet? Start off with #InstallKeybdHook at the top of the script.

I just looked in hook.cpp in the AHK source code, here's the hook it installs:
if (   !(g_KeybdHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeybdProc, g_hInstance, 0))   )

The WH_KEYBOARD_LL is the low-level hook.

Hooks are a good way to get notified when a keyboard or mouse event happens. The 'hook chain' starts with the last program that installs a hook. That program gets notified that something has happened, then it can choose to either pass the event on to the next hook, process it and make some changes to the reported event and then pass it on, or just not pass it on at all.

So if you start a game, then start a script with a keyboard hook and none of the hotkeys are firing (best test is with a script that pops a message box on a hotkey), chances are that the game is doing something to try to keep its hook at the top of the chain and just not passing the info on to the next hook. In that case you are pretty limited in what you can do with a script that will work while the game is running.

Maybe instead of starting on a hotkey, use a timer? Or sleep? I can see that being a PITA though.

Anyhow, that's my knoweldge of how hooks work. If I'm wrong or missed something, someone will surely point it out I hope. But I think that is the basics as far as your AHK scripts will go.

After that, you have the problem that AHK might get the event info from a hook, but simply isn't sending keyboard/mouse events that will work in the game. At this point, is has nothing to do with the hook your script installed, but the Send method that AHK is using and the way the game is getting/interpreting keystrokes.

While a hook is popular, it is not the only way a game can poll keyboard/mouse events. For example, in DirectX, a program can set DirectInput up in a way where it has exclusive use of an input device as long as the device is not 'lost' (i.e. the program's window is foreground and has focus). This is probably one way to make it hard to macro. I haven't tested AHK with a known DirectInput program using this method yet, but I'm planning on it as I'm using DI for something I'm currently working on.

Anhow, in this case, it really doesn't matter what hook you use. The problem wouldn't be the hook, but other factors. All you can really do is try different Send methods and hope it works.

Sorry about the essay, but I've been thinking about this problem for some time now and was trying to get my head around what to do about it. Just thought I'd share what I think I know, feel free to correct me if I have any of it wrong :)

PS... If you want to know one trick that might work on some of the tougher games, might look into JournalRecord/JournalPlayback. That may be one way to get through to the game. I really don't know how well it works, but I might test it one of these years.

Physical
  • Guests
  • Last active:
  • Joined: --
Thanks for the replies, you have given me some ideas. Zippo if you want to try yours the game i am playing is 9Dragons. a program called autopro is able to work with no problems, even if its run after the game is running. It is the one that costs 40$ and i really dont feel like buying it so i am going to keep trying things. I will try making a script in AHK using its hook and see if it works. Thx for help both of you.