SimInput Documentation

Simulate mouse and keyboard inputs globally in GameMaker.

SimInput is a GameMaker extension for Windows that lets you simulate mouse and keyboard input. This can be used for interfacing with your game or even other programs programmatically, as if you were clicking or typing manually. Useful for automating testing of your game, or developing macros for other software.

Mouse functionality

Here's a complete example, showing how to simulate a click-and-drag followed by a single right click:

Clicking and dragging

Getting the mouse position directly

In GameMaker, you can use keyboard_check_direct() to detect keyboard keys being pushed even when the window doesn't have focus. This extension adds mouse_check_button_direct(button) for checking for mouse clicks in a similar way, even if the game is not in focus:

Checking for global mouse clicks

Keyboard functionality

Simulating key presses works similarly to mouse clicks:

Typing out a word

You can pass in any of the usual constants that you would use for GameMaker's built-in keyboard functions, including using ord() for letters. There are a few extra macros included for things like the Windows key, volume keys, media keys, caps lock, and a few others (full list below). This means you can control system audio from your game:

Controlling system audio

Index

Mouse

  • simulate_mouse_click(button) - Simulates a mouse click wherever the cursor currently is
  • simulate_mouse_down(button) - Simulates a mouse button being pushed down wherever the cursor currently is
  • simulate_mouse_up(button) - Simulates a mouse button being released wherever the cursor currently is
  • simulate_mouse_move(x, y) - Simulates mouse movement relative to its current position
  • simulate_mouse_scroll(y) - Simulates mouse wheel movement
  • os_mouse_position_set(x, y) - Moves the mouse to a specific spot on the screen
  • os_mouse_position_x() - Returns the mouse x position on the screen
  • os_mouse_position_y() - Returns the mouse y position on the screen
  • mouse_check_button_direct(button) - Check for a mouse button being held down, even if the window is not in focus

Keyboard

  • simulate_keyboard_press(key) - Simulate a keyboard key press
  • simulate_keyboard_down(key) - Simulate a keyboard key being pushed down
  • simulate_keyboard_up(key) - Simulate a keyboard key being released

Keyboard Macros

  • vk_numlock
  • vk_scrolllock
  • vk_capslock
  • vk_lwin
  • vk_rwin
  • vk_win
  • vk_volume_mute
  • vk_volume_down
  • vk_volume_up
  • vk_media_next_track
  • vk_media_previous_track
  • vk_media_stop
  • vk_media_play_pause