最近GTA5刚解锁了地堡,可是生产货物必须得在线才可以,而且得有动作,不然就会被认为发呆踹下线,但升级了安保系统后就可以看监控,但手动按键盘太枯燥,写个脚本帮你自动按键,这样就可以完美的解决这个问题哇。
Windows: pip install pynput ( 记得管理员权限运行cmd哇! )
Linux: sudo pip install pynput
from pynput import keyboard
def on_press(key):
print(key);
# 按下
def on_release(key):
print(key);
# 中断监听 return False
# 抬起
# 开始监听
with keyboard.Listener(on_press=on_press,on_release=on_release) as listener:
listener.join()
# 结束监听 从任何地方调用pynput.mouse.Listener.stop,
# 或者调用pynput.mouse.Listener.StopException
# 或从回调中返回False来停止监听器
# gta5_摸鱼
from pynput import keyboard
import time,os,signal,threading
print('ESC = 退出程序 F11 = 停止程序 F12 = 开始程序')
flag = True # 摸鱼开关变量
# 键盘全局监听函数时间事件
def stop():
def on_press(key):
pass
def on_release(key):
global flag
if key == keyboard.Key.esc:
print('退出摸鱼')
os.kill(os.getpid(), signal.SIGTERM)
elif key == keyboard.Key.f12:
print('继续摸鱼')
flag = True
elif key == keyboard.Key.f11:
print('停止摸鱼')
flag = False
else:
pass
with keyboard.Listener(on_press=on_press,on_release=on_release) as listener:
listener.join()
# 启动监听进程
t = threading.Thread(target=stop)
t.start()
def main():
print('正在摸鱼!')
keyboardController = keyboard.Controller();
while True:
if flag == True:
keyboardController.press('a')
keyboardController.press('w')
else:
continue
print('5s后自动开始程序')
time.sleep(5)
main()
游戏屏蔽模拟按键了,歇逼。。。。。。但是拿来改改当个 “猎人” 还是不错的