Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Trying to install inputsimulator Plugin

Discussion in 'Scripting' started by ffertigo, Apr 7, 2018.

  1. ffertigo

    ffertigo

    Joined:
    May 31, 2015
    Posts:
    12
    I want to simulate a keyboard key and found the plugin inputsimulator from here: https://archive.codeplex.com/?p=inputsimulator


    But it seems I can't get it to install right. I put the folder inputsimulator from the folder sourceCode to my Asset folder. It seems that the library is recognized in Monodevelop but i don't get all the methods like in this screen from their website that should be there:





    It also doesn't work when i type something like:
    InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_A);

    I get this error in the console with the code above: WindowsInput.InputSimulator' does not contain a definition for `SimulateKeyPress'




    Do I need to compile the sourcecode first from the plugin or how can i install it? I know many people are using this plugin in unity. Thanks in advance!
     
    Last edited: Apr 7, 2018
  2. gfoxworthy

    gfoxworthy

    Joined:
    Nov 4, 2010
    Posts:
    24
    Bump... It's not working for me either!
     
  3. gfoxworthy

    gfoxworthy

    Joined:
    Nov 4, 2010
    Posts:
    24
    After spending a little more time with it, I discovered how to properly get this working in Unity 2017.3.1.

    The code below will create a new InputSimulator. I have a Canvas in my scene, with a UI Button that calls ButtonPress (rigged in the editor). It works!

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using WindowsInput;
    6.  
    7. public class Test : MonoBehaviour
    8. {
    9.  
    10.     InputSimulator IS;
    11.  
    12.     // Use this for initialization
    13.     void Start()
    14.     {
    15.         IS = new InputSimulator();
    16.     }
    17.  
    18.     public void ButtonPress()
    19.     {
    20.         IS.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VK_A);
    21.     }
    22.  
    23.     // Update is called once per frame
    24.     void Update()
    25.     {
    26.         if (Input.GetKeyDown(KeyCode.A))
    27.         {
    28.             Debug.Log("A");
    29.         }
    30.     }
    31.  
    32.  
    33.  
    34. }
    35.  
     
    chelnok likes this.
  4. yousuffahim8

    yousuffahim8

    Joined:
    Feb 21, 2019
    Posts:
    3
    @gfoxworthy How did you run Input Simulator in Unity. I cannot import "using WindowsInput;". Please help me.
     
  5. bekiryanik

    bekiryanik

    Joined:
    Jul 6, 2014
    Posts:
    191
    I couldn't run input simulator too. Is there anyone who knows how to do it?
     
  6. geoapps33

    geoapps33

    Joined:
    Aug 31, 2018
    Posts:
    1
    Hello everyone after some installation problems in unity that are solved by deleting some files, I was able to run the code I needed ... THANK YOU BUT THANK YOU MY FRIENDS for the help
     
  7. miraclestar

    miraclestar

    Joined:
    Oct 26, 2015
    Posts:
    14