New instrument which allows to initialize hotkeys right from scripts.
[Keybind("p")] // Simple example - triggers when 'p' is pressed
[Keybind("Ctrl+2")] // Triggers only when 'Ctrl + 2' is pressed
[Keybind("Ctrl+2", IgnoreModifiers = true)] // Triggers on ANY combination containing 'Ctrl + 2' (e.g., 'Ctrl + Alt + 2')
public void OnKey(){
Log.Info("Key pressed");
}
[Keybind(Hotkey = "4", SuppressKey = false)] // Handles the key, but it will still pass through to other apps
public void HandleKeyWithInjectedServices(IAuraEventLoggingService loggingService){
Log.Info("Key pressed");
loggingService.LogMessage(new AuraEvent(){ Text = "Message", Loglevel = FluentLogLevel.Info });
}
If you're using GetService
somewhere in the code - you're already using DI system in EyeAuras.
I've made some improvements in that part which should simplify the scripts
Here is how exactly same script looks like in 3 different forms:
Current approach - get APIs via GetService
var sendInput = GetService<ISendInputScriptingApi>();
sendInput.MouseMoveTo(200, 100); // Moves the mouse to X200 Y100
sendInput.MouseRightClick(); // Performs a right mouse click
Now two new approaches which you could(and should!) start using in your scripts.
I am thinking about automatically injecting current APIs (such as SendInput) into your scripts - this would simplify and generalize the code.
E.g. for ISendInputScriptingApi
the name would be SendInput
(like in example below), for IPlaySoundScriptingApi
- PlaySound
, for ComputerVision
that could be something like IComputerVisionExperimentalScriptingApi Cv { get; init; }
I will publish this as a separate update.
ISendInputScriptingApi SendInput { get; init; } // Automatically initialized when the script starts
SendInput.MouseMoveTo(200, 100); // Moves the mouse to X200 Y100
SendInput.MouseRightClick(); // Performs a right mouse click
Now
[Dependency] ISendInputScriptingApi SendInput { get; set; }
SendInput.MouseMoveTo(200, 100); // Moves the mouse to X200 Y100
SendInput.MouseRightClick(); // Performs a right mouse click