Sign in to follow this  
Followers 0
Visionz

Other Program Capturing Keys?

12 posts in this topic

I am trying to make a hot key for my script, however, while running the game i am trying to run this script on, AutoIt doesnt receive the keys.

Now obviously this game has hooked the keys itself to be able to control things in the game...now is there a way to be able to get AutoIt to receive these keys also? I notice that my keyboard software is still able to change the caps lock, numlock, etc. state (and also display the words "Caps Lock On/Off" on my screen) so that program is obviously receiving that key, but it doesnt work with AutoIt..any suggestions? Thanks.

Share this post


Link to post
Share on other sites



The following hotkeys cannot be set:

...

Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'.

So no, you can't set a hotkey your game uses without unregistering the hotkey from the game.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

So if the game has ALL the keys registered then you cant do anything? My keyboard software still captures the caps lock key so shouldnt autoit be able to? It works while the game isnt running, even tried closing the keyboard software to no avail... Could it be windows xp? Theres gotta be a way..

Share this post


Link to post
Share on other sites

My keyboard software still captures the caps lock key so shouldnt autoit be able to?

It doesn't work that way. Both programs are likely using a hook to capture that key, and AutoIt doesn't install event hooks.

I also can't imagine that a game has captured all key combinations. There are about 650 different key combinations you make on a standard keyboard with the control, alt, and shift modifiers (for 7 base combinations for modifier keys.) I can't imagine that a game has hooked all of these keys.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Well i guess i will try some more, but it has tons hooked... Perhaps it has some kind of protection to stop programs like autoit i dunno ill keep trying thanks.

Share this post


Link to post
Share on other sites

It also depends on what your functions that you're hotkeying do. If they send keys, it's possible that the hotkey itself is working fine, but that the game is blocking the keys you are sending via AutoIt. You could try writing to a file when a function is executed to see if the function is being run or not.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Do you have AIM or something i could talk to you on perhaps?

Anyways, i tried several hotkeys like shift+home ctrl+alt+home capslock ins etc etc. Nothing works. All i am trying to do is pause the macro IE:

Global $Paused

HotKeySet("+{INS}", "TogglePause")

While 1

Sleep(100)

WEnd

Func TogglePause()

$Paused = NOT $Paused

MsgBox(1,"OK","OK")

While $Paused

sleep(100)

WEnd

EndFunc

I have the msgbox come up to see if it works or not. But nothing ever works. AutoIt must use hotkeys differnetly or something because like i said the caps lock key is captured by my keyboard software...but i tried it with autoit and still didnt work.

Share this post


Link to post
Share on other sites

Your keyboard software is doing one of two things, it's either capturing keys all the way down at the device driver level (This would imply some interaction which goes on between the software itself and the actual device driver which makes it work). Or it's installed a keyboard hook into the system by using a DLL and the WH_KEYBOARD hook.

The game itself has likely installed a WH_KEYBOARD hook as well. If it has, then it's very simple to simply stop the key from being processed right then and there. The game can use it because it has caught it, but it can safely throw it away so no other hook procedure or window every sees it.

AutoIt does not use a keyboard hook (or any other hook for that matter). It's not likely that the official build ever will, either. It's been discussed many times, both for keyboard and mouse hooks, and it's not going to happen for various reasons.

AutoIt is a Windows automation tool. It wasn't designed with game automation in mind. A good thought to have in mind when you try to use AutoIt and a game is that the rules of what should and shouldn't work in regards to the keyboard and mouse are out the window.

Share this post


Link to post
Share on other sites

Visionz asked me this in private, however, I wish to reply publicly just to demonstrate what a little creative thinking can do.

Alright, do you know of any way i could interact with AutoIt (IE to pause a macro) assuming that the game does use that method?

I have limited programming knowledge, and i have VB, VC++, and delphi. Would it be possible to make a systemwide hotkey or what not with one of those to override the game and when the hotkey is pressed, simulate the keypress for the autoit hotkey?

Or perhaps there is another method i could use to pause the game, but if not by using the keyboard then what?

I appreciate your help, thanks.

I thought about various C++ ways to do it, then the most laughably simple idea came to me. If you have a floppy drive on your PC, you have an on/off switch for anything. But more than that (Details later, code first).

Here's a very simple concept:

Global $pause = 0
While 1
    If Not $pause And DriveStatus("A:") = "READY" Then
        $pause = 1
        TrayTip("", "", 5, 16)   ;; Clear our little "Doing something" message.
    ElseIf $pause And DriveStatus("A:") = "NOTREADY" Then
        $pause = 0
    ElseIf $pause Then
        Sleep(1000)
    Else
        TrayTip("Doing something", "Stuff", 5, 16)
    EndIf
    Sleep(50)
Wend

This script does stuff until you put a disk in drive A:. Then it pauses, once you take the disk back out, it continues. Simple as that.

Here's where it gets fun, however. What if you put name files on different disks? After all, the above method only pauses the script, you still have no way of exiting. How about this, then? (From this point, the code is untested, but it should all work).

If Not $pause And DriveStatus("A:") = "READY" Then
    If FileExists("A:\exit.txt") Then 
       ; Clean up or whatever needs done
        Exit
    EndIf
    $pause = 1
    TrayTip("", "", 5, 16)   ; Clear our little "Doing something" message.

All that's required are some floppies and you can set up whatever options you need. You can have as many features as you own floppy disks, each one having some unique file name or a label or something to distinguish one from another. These can be the catalyst to trigger events in the event that hotkeys won't work.

Share this post


Link to post
Share on other sites

Mmmm interesting idea :ph34r: I kept thinking of a way to interact with AutoIt...ie taking a screenshot ingame then seeing if the screen shot existed, pause, etc., but this way would be even better. While being able to capture the keys would be best, this way will have to work :(

Thanks, ill test this out tonight :lol:

Share this post


Link to post
Share on other sites

It is interesting as I am also thinking the same thing for my game.

This is an idea I come out with.

Do something that will change the game scene that is unique.

For my case, since the game allow me to type in characters, I can type in sentence like

"Stop the game now".

The scene on the game will change with the words appear.

Capture the image by using Print screen.

Figure out the change in pixels when the sentence "Stop the game now" appear.

I use adobe photoshop to do it but many commercial software will work.

Have your autoit script polls for the pixel colors at certain pixels every 250ms, I randomly pick a few pixels that the sentence "Stop the game now" appear at:

If PixelGetColor(x1, y1)=color1 And PixelGetColor(x2, y2)=color2.... then

pause and keep checking for unpause condition;

EndIf

You can use adlib or just do:

while 1

If PixelGetColor(x1, y1)=color1 And PixelGetColor(x2, y2)=color2.... then

pause and keep checking for unpause condition;

EndIf

sleep(250)

WEnd

for polling.

To unpause, you may need to do the same thing, and type in some sentence like "unpause the game" and try to detect the pixel change.

Of course, if you game cannot key in something thing, you might want to do something else to change the scene. Say open up your inventory and put on a rarely use armor to create scene change for pause/unpause indications.

Hope that helps.

Share this post


Link to post
Share on other sites

In February I created an AsyncHotKeySet() script to solve this problem. It has to be polled from within your script but it does the trick.

AsyncHotKeySet post.

B.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0