Search Unity

GUI button press sendkeys

Discussion in 'Scripting' started by RingOfStorms, Feb 17, 2011.

  1. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    So I am still messing around with my script and adding more and more functionality.

    ATM I want to do something like this:
    How would I write this? what is the correct way (if any) to do a send-key.
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I don't believe there is a command like that. But why not just execute the code when the button is pushed. Like if you are calling function DoSomething() when you hit the space key, then just call DoSomething() when you bush your GUIButton.
     
  3. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    Well the problem with that is, if I press down it will work fine, but I also have a if statement for when you release so, if there a if(GUIbutton- released)
    Otherwise that wont really work
     
  4. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    So is there a way to say it's not pressed to do "bla bla bla"
     
  5. sinxtanx

    sinxtanx

    Joined:
    Feb 18, 2011
    Posts:
    25
  6. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    yes there is

    just use and or ( || ) statement in your if to make if space is pressed or the the GUI button is pressed.
     
  7. Sadaan

    Sadaan

    Joined:
    Dec 10, 2014
    Posts:
    15
    Hi i want something like that. So the scenario is I only have to get input from a joystick in Unity exe. But i have to run another program with unity exe that does not take joystick input so i have to send it the a simulated event trigger keypress from the exe of Unity when that joystick button is pressed. Can anyone help me with this?
     
  8. arthurconnor100

    arthurconnor100

    Joined:
    Jun 13, 2017
    Posts:
    6
    I know this is a bit late of a response, but I am trying to do the same thing. Right now I am using the sendkeys.send function, but am having some trouble getting it to work properly. Let me know if you found a more effective way to do this.
     
  9. dodget3

    dodget3

    Joined:
    May 25, 2018
    Posts:
    3

    did you ever figure this out? I'm having a similar issue.