如何使用python向正在玩的游戏发送密钥? [英] How can I send keys to a game I am playing,using python?
问题描述
我正在玩人类的革命,用正确的4位数代码可以访问某些东西.
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 keystrokes to the game. I have tried using send keys but i could not make it work.Any ideas?Thanks.
-SendKeys
这是我尝试过的,我在这里找到了:
This is what I have tried,which I found here:
import win32com.client
import time
import SendKeys
import os
from ctypes import *
shell = win32com.client.Dispatch("WScript.Shell")
os.startfile('C:\\....exe')
time.sleep( 150 )
shell.SendKeys('1')
我最初尝试的方法是使用脚本打开游戏,延迟加载保存游戏的时间,然后打开终端对其进行破解,但是密钥没有发送.
The way I am trying at first is open the game with the script,put a time delay to load the save game,and I open a terminal to hack it, but the key is not send.
-pywinauto:
使用pywinauto我有这个:
Using pywinauto I have this:
from pywinauto import application
import time
app=application.Application()
app.connect_(title_re = "Deus Ex: Human Revolution - The Missing Link", class_name = "DeusExHRE")
现在,我正在搜索可用的对话框.
Now I am searching which dialogs are available.
因此,除了python之外,我正在尝试使用AutoHotKeys:
So except from python,I am trying with AutoHotKeys:
这有效:
SetKeyDelay 180
F12::
Send {0 down}
Send {0 up}
Send {0 down}
Send {0 up}
Send {0 down}
Send {0 up}
Send {0 down}
Send {0 up}
Send {Backspace down}
Send {Backspace up}
Return
keydelay是我发现的没有错过任何按钮的最小值.我正在寻找一种使之更快的方法,也许是通过使用其他发送方法来实现的.
The keydelay is the minimum I found that didn't miss any buttons.I am looking for a way to make it faster,maybe by using a different send method.
已更新:
-pywinauto -autohotkeys
-pywinauto -autohotkeys
推荐答案
您是否尝试过此吗?
这篇关于如何使用python向正在玩的游戏发送密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!