0
from time import sleep, time
import win32api
import win32gui, win32ui, win32con

VK_KEY_W = 0x57
VK_KEY_A = 0x41
VK_KEY_S = 0x53
VK_KEY_D = 0x44
VK_KEY_P = 0x50
VK_SHIFT = 0xA0
VK_F1 = 0x70

def main():
    window_name = "Aeldra"
    hwnd = win32gui.FindWindow(None, window_name)
    win32gui.SetForegroundWindow(hwnd)
    press_key(hwnd, VK_F1, 0.4)
    list_window_names()


def press_key(hwnd, key, sec):
    win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, key, 0)
    sleep(sec)
    win32api.SendMessage(hwnd, win32con.WM_KEYUP, key, 0)

def list_window_names():
        def winEnumHandler(hwnd, ctx):
            if win32gui.IsWindowVisible(hwnd):
                print(hex(hwnd), win32gui.GetWindowText(hwnd))
        win32gui.EnumWindows(winEnumHandler, None)

main()

Hello i want to make a bot like clicking objects in a games but the code is not working at the game the inputs i send is not working in game but when i send inputs to another thing its working.

  • Your problem could possibly be linked to this question: https://stackoverflow.com/questions/38970354/win32gui-findwindow-not-finding-window – NewbieCody Aug 03 '22 at 12:04
  • Does this answer your question? [win32gui.FindWindow Not finding window](https://stackoverflow.com/questions/38970354/win32gui-findwindow-not-finding-window) – EJZ Aug 04 '22 at 12:45

0 Answers0