gpt4 book ai didi

用于游戏的 Python 一键宏

转载 作者:行者123 更新时间:2023-11-28 17:15:19 24 4
gpt4 key购买 nike

这是我的 Python 2.7.13 脚本,基本上是视频游戏的所谓“一键宏”。根据从游戏屏幕的一部分捕获的信息,它会代替玩家按下正确的组合键。因此,播放器向 f 键发送垃圾邮件,脚本会按下 f 旁边的其他键。

它按原样工作,但在随机时间(启动后 1-5 分钟)脚本会停止或类似的情况。我可以在 Windows 任务管理器中看到脚本正在运行,但是当我按下 f 键时没有任何反应。

一开始我写的代码有点未优化,它不止一次截图/按键。那时脚本“卡住”的频率更高。

会不会是截图太多的缘故?还是我哪里搞砸了?

import pyautogui, pythoncom, pyHook

# Determine if an ability is ready or not

def ready(x,y, im):
if (im.getpixel((x,y)) != (0,0,0)):
return True
else:
return False

def ability1(im):
return (ready(17, 16, im) or ready(35, 16, im))


def ability2(im):
return ready(134, 9, im)

# Listen for keypress
def OnKeyboardEvent(event):
im = pyautogui.screenshot(region=(249, 770, 194, 26))

if (event.KeyID == 70): # Pressed the "f" key
if (ability1(im)):
pyautogui.hotkey('shift','4')
return True

if (ability2(im)):
pyautogui.press('-')
return True

pyautogui.press('1')
return True

# create a hook manager
hm = pyHook.HookManager()

# watch for all mouse events
hm.KeyDown = OnKeyboardEvent

# set the hook
hm.HookKeyboard()

# wait forever
pythoncom.PumpMessages()

最佳答案

如果您在实时服务器上运行它,这可能是由于 Warden 增加了检查/干扰。

我建议不要在实时服务器上使用这种自动化,如果被发现可能会导致被禁止。

关于用于游戏的 Python 一键宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44566646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com