FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login
    The current pre-release of the client ("pioneer" in the version) is only compatible to itself. So you can only play with other testers. Please be aware!

    Arrows -> WASD

    Scheduled Pinned Locked Moved Modding & Tools
    1 Posts 1 Posters 38 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      CEPHALON
      last edited by

      This simple script emulates pressing the arrows by pressing WASD (W - Up, A - Left, S - Down, D - Right). I will also attach the source code of the script. The script works in cloud mode ONLY on the Supreme Commander Forget Alliance window, controlled by the hotkey Alt+F2 (Enable/Turn it off)

      Google Drive: https://drive.google.com/drive/folders/1HtBEZ7L_6n4-hX_7H9FySJ3FtljUY_uw?usp=sharing

      CODE:

      ***import time
      *from pynput import keyboard
      from pynput.keyboard import Controller, Key
      import win32gui

      Контроллер для эмуляции нажатий клавиш

      kb = Controller()

      Словарь соответствия WASD → стрелки

      wasd_to_arrow = {
      'w': Key.up,
      'a': Key.left,
      's': Key.down,
      'd': Key.right
      }

      Название окна Supreme Commander: Forged Alliance (точно, как в заголовке)

      TARGET_WINDOW = "Supreme Commander: Forged Alliance"

      Флаг работы скрипта

      running = True
      pressed_keys = set()

      def is_target_window_active():
      hwnd = win32gui.GetForegroundWindow()
      title = win32gui.GetWindowText(hwnd)
      return TARGET_WINDOW.lower() in title.lower()

      def on_press(key):
      global running
      try:
      # Alt+F2 — остановка скрипта
      if key == Key.f2 and Key.alt in pressed_keys:
      running = False
      return False

          # Добавляем клавишу в множество нажатых
          pressed_keys.add(key)
      
          if hasattr(key, 'char') and is_target_window_active():
              char = key.char.lower()
              if char in wasd_to_arrow:
                  kb.press(wasd_to_arrow[char])
      
      except AttributeError:
          pass
      

      def on_release(key):
      # Убираем клавишу из множества нажатых
      if key in pressed_keys:
      pressed_keys.remove(key)

      # Отпускаем стрелку если отпустили WASD и окно активно
      if hasattr(key, 'char') and is_target_window_active():
          char = key.char.lower()
          if char in wasd_to_arrow:
              kb.release(wasd_to_arrow[char])
      

      Запуск слушателя

      with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
      listener.join()****

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post