Skip to content Skip to sidebar Skip to footer

How Can I Send Keys To A Game I Am Playing,using Python?

I am playing deus ex human revolution,and there are things you can access with the correct 4 digit code. I was wondering if you could make a script to brute force it sending keystr

Solution 1:

Have you ever tried this ?

Solution 2:

You've probably already thought of this but just in case, make sure you try your solution(s) in a couple of places. IIRC, there's a couple of spots in Deus Ex where you have to discover the code in-game before you can use it, even though the code itself is hard-wired into the game.

What'd be really cool is if you got something to do the hacking mini-games automatically. :)

Solution 3:

Some years late, but answering anyway as other might face the same problem like I did...

In Windows you can use win32api to send keys to the active application, but you have to give it a scan code also to make it work in some types of applications such as games

To send a single key, you must have it's virtual key code that you can get either by using the solution Here or by having a dictionary (that you can easily find done in google or make it yourself)

MapVirtualKey

keybd_event

import win32api, win32con, time# in this example i'm using a dictionary (that i called VK_CODE)# to map the keys to their respective virtual key codes# Sending the key a
i = 'a'# send key down event
win32api.keybd_event(VK_CODE[i], win32api.MapVirtualKey(VK_CODE[i], 0), 0, 0)

# wait for it to get registered. # You might need to increase this time for some applications
time.sleep(.05)

# send key up event
win32api.keybd_event(VK_CODE[i], win32api.MapVirtualKey(VK_CODE[i], 0), win32con.KEYEVENTF_KEYUP, 0)

Post a Comment for "How Can I Send Keys To A Game I Am Playing,using Python?"