How use KeyBoardAPI?

watsitfts

Member
Member
Aug 21, 2017
57
27
8
39
Parts Unknown
Fougerite Version: 151
RustBuster Version (If used): 195
Explain us the problem: Hi everyone. Anybody know how use KeyBoardAPI?? Please... any example?? I can't load using VisualStudio... Thanks.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
3,960
1,188
113
At your house.
github.com
C#:
// Simulate that the key is being pressed down.
KeyboardAPI.SendKey(KeyboardAPI.DirectXKeyStrokes.DIK_F2, false, KeyboardAPI.InputType.Keyboard);
// Simulate that the key is not pressed anymore, therefore It was pressed.
KeyboardAPI.SendKey(KeyboardAPI.DirectXKeyStrokes.DIK_F2, true, KeyboardAPI.InputType.Keyboard);
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
3,960
1,188
113
At your house.
github.com
Here is the example by @salva , with a small addition:

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using RustBuster2016.API;

namespace TEEEEESSSSSTTTTT
{
    public class PluginGUI : MonoBehaviour
    {
        public void OnGUI()
        {
            if (GUI.Button(new Rect(100, 100, 200, 30), "open console"))
            {
                RustBuster2016.API.KeyboardAPI.SendKey(KeyboardAPI.DirectXKeyStrokes.DIK_F1, false, KeyboardAPI.InputType.Keyboard);
                //RustBuster2016.API.KeyboardAPI.SendKey(KeyboardAPI.DirectXKeyStrokes.DIK_F1, true, KeyboardAPI.InputType.Keyboard);
            }
}}}