How to Press Random Key
How to Press Random Key
- Create an aura.
- Add
HotkeyIsActiveto it and bind it to a convenient button (this will be our on/off switch, in the example it'sF3), change the activation type toClick/Hold. - Add a
C# Scriptaction toOn Enter. - Copy and paste the script itself.
- Focus the application that should receive input. Pressing
F3sends one of1,2,4,5,A, orD.
using EyeAuras.Roxy.Api;
using System.Windows.Input;
var randomKeys = new[] { Key.D1, Key.D2, Key.D4, Key.D5, Key.A, Key.D }; // list your random keys here
var input = GetService<ISendInputScriptingApi>();
input.TargetWindow = null;
input.KeyPress(randomKeys[System.Random.Shared.Next(randomKeys.Length)]);
Each aura entry picks one key and sends one press. KeyPress is synchronous, takes no Run token, and uses the API press/release delay. GetService is supplied by the script host; an ordinary class must receive the input service explicitly.