TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Trigger a command from Unity

    Instructions
    1
    1
    446
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RussR
      Russ
      last edited by Russ

      This is an example script you can put on any object in Unity, so now you can trigger commands in the games you build.

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.Networking;
      
      public class scr : MonoBehaviour
      {
          // Start is called before the first frame update
          void Start()
          {
              
          }
      
          // Update is called once per frame
          void Update()
          {
              if (Input.anyKeyDown)
              {
                  Debug.Log("A key or mouse click has been detected");
      
                  var trigger = "calculator";
                  var computer = "laptop";
                  var parameters = "";
                  var token = "(your token)";
                  StartCoroutine(TriggerCMD(trigger, computer, parameters, token));
              }
          }
      
          IEnumerator TriggerCMD(string trigger,string computer,string parameters, string token)
          {
              UnityWebRequest www = UnityWebRequest.Get("https://www.triggercmd.com/api/run/triggerSave?trigger=" + trigger + "&computer=" + computer + "&params=" + parameters + "&token=" + token);
              yield return www.SendWebRequest();
      
              if (www.isNetworkError || www.isHttpError)
              {
                  Debug.Log(www.error);
              }
              else
              {
                  // Show results as text
                  Debug.Log(www.downloadHandler.text);
      
                  // Or retrieve results as binary data
                  byte[] results = www.downloadHandler.data;
              }
          }
      }
      

      I created an example VR app for Oculus Quest to demonstrate. I recommend using SideQuest to install it.

      Russell VanderMey

      1 Reply Last reply Reply Quote 0
      • RussR Russ referenced this topic on
      • First post
        Last post