I’m trying to move the character in the game Wuthering waves using python code. I’ve tried many libraries but the character still doesn’t move. Like pydirectinput, pynput, ctypes, win32api.
using pydirectinput
import time
import pydirectinput
pydirectinput.FAILSAFE = False
def press_key(key):
pydirectinput.keyDown(key_dict[key])
time.sleep(0.1)
pydirectinput.keyUp(key_dict[key])
time.sleep(0.1)
while True:
press_key('a')
using ctypes:
import time
import ctypes
PUL = ctypes.POINTER(ctypes.c_ulong)
class KeyBdInput(ctypes.Structure):
_fields_ = [("wVk", ctypes.c_ushort),
("wScan", ctypes.c_ushort),
("dwFlags", ctypes.c_ulong),
("time", ctypes.c_ulong),
("dwExtraInfo", PUL)]
class HardwareInput(ctypes.Structure):
_fields_ = [("uMsg", ctypes.c_ulong),
("wParamL", ctypes.c_short),
("wParamH", ctypes.c_ushort)]
class MouseInput(ctypes.Structure):
_fields_ = [("dx", ctypes.c_long),
("dy", ctypes.c_long),
("mouseData", ctypes.c_ulong),
("dwFlags", ctypes.c_ulong),
("time", ctypes.c_ulong),
("dwExtraInfo", PUL)]
class Input_I(ctypes.Union):
_fields_ = [("ki", KeyBdInput),
("mi", MouseInput),
("hi", HardwareInput)]
class Input(ctypes.Structure):
_fields_ = [("type", ctypes.c_ulong),
("ii", Input_I)]
def press_key(hexKeyCode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput(hexKeyCode, 0x48, 0, 0, ctypes.pointer(extra))
x = Input(ctypes.c_ulong(1), ii_)
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
def release_key(hexKeyCode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput(hexKeyCode, 0x48, 0x0002, 0, ctypes.pointer(extra))
x = Input(ctypes.c_ulong(1), ii_)
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
key_dict = {
'A': 0x1E,
'SPACE': 0x39,
'ENTER': 0x1C,
'UP': 0xC8,
'DOWN': 0xD0,
'LEFT': 0xCB,
'RIGHT': 0xCD
}
while True:
press_key(key_dict['A'])
time.sleep(0.1)
release_key(key_dict['A'])
time.sleep(0.1)
I would like to have python code that can help me move the character in the game
New contributor
TokaiTeio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.