SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Net;
  6. using System.Net.Sockets;
  7. using System.Reflection;
  8. using System.Runtime.InteropServices;
  9. using System.Runtime.Serialization.Formatters.Binary;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using MiscUtil;
  14. namespace RemoteControl
  15. {
  16.     class Program
  17.     {
  18.  
  19.         static void Main(string[] args)
  20.         {
  21.             //Spam A
  22.             while (true)
  23.             {
  24.                 Console.WriteLine("Send Key");
  25.  
  26.                 //Send Input
  27.                 SendInput("192.168.1.15", Keys.A, 50).GetAwaiter().GetResult();
  28.                 //Free Input
  29.                 SendInput("192.168.1.15", Keys.None, 50).GetAwaiter().GetResult();
  30.             }
  31.  
  32.             //Console.ReadKey();
  33.         }
  34.  
  35.         public class Keys
  36.         {
  37.             public const uint None = 0;
  38.             public const uint A = 1;
  39.             public const uint B = 1 << 1;
  40.             public const uint X = 1 << 2;
  41.             public const uint Y = 1 << 3;
  42.             public const uint LEFT_STICK = 1 << 4;
  43.             public const uint RIGHT_STICK = 1 << 5;
  44.             public const uint L = 1 << 6;
  45.             public const uint R = 1 << 7;
  46.             public const uint ZL = 1 << 8;
  47.             public const uint ZR = 1 << 9;
  48.             public const uint PLUS = 1 << 10;
  49.             public const uint MINUS = 1 << 11;
  50.             public const uint DPAD_LEFT = 1 << 12;
  51.             public const uint DOWN_UP = 1 << 13;
  52.             public const uint DPAD_RIGHT = 1 << 14;
  53.             public const uint DPAD_DOWN = 1 << 15;
  54.             public const uint LEFT_ANALOG_LEFT = 1 << 16;
  55.             public const uint LEFT_ANALOG_UP = 1 << 17;
  56.             public const uint LEFT_ANALOG_RIGHT = 1 << 18;
  57.             public const uint LEFT_ANALOG_DOWN = 1 << 19;
  58.             public const uint RIGHT_ANALOG_LEFT = 1 << 20;
  59.             public const uint RIGHT_ANALOG_UP = 1 << 21;
  60.             public const uint RIGHT_ANALOG_RIGHT = 1 << 22;
  61.             public const uint RIGHT_ANALOG_DOWN = 1 << 23;
  62.             public const uint SL = 1 << 24;
  63.             public const uint SR = 1 << 25;
  64.         }
  65.  
  66.         private static uint get_key_state(uint Key, int Status)
  67.         {
  68.             uint Out = 0;
  69.  
  70.             if (Status >= 0)
  71.             {
  72.                 Out |= Key;
  73.             }
  74.             else
  75.             {
  76.                 Out &= ~Key;
  77.             }
  78.  
  79.             return Out;
  80.         }
  81.  
  82.         public static async Task SendInput(string host, uint Key, int Delay)
  83.         {
  84.  
  85.             var client = new UdpClient();
  86.  
  87.             IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(host), 8080); // Build a UDP Socket
  88.  
  89.             MemoryStream stream = new MemoryStream(26);
  90.             using (BinaryWriter writer = new BinaryWriter(stream))
  91.             {
  92.                 writer.Write((UInt16)0x3275);
  93.                 writer.Write((UInt64)get_key_state(Key, 0));
  94.                 writer.Write((Int16)0);
  95.                 writer.Write((Int16)0);
  96.                 writer.Write((Int16)0);
  97.                 writer.Write((Int16)0);
  98.  
  99.                 client.Send(stream.ToArray(), (int)stream.Length, endpoint); // Send Input
  100.  
  101.             }
  102.  
  103.             await Task.Delay(Delay); // Delay
  104.         }
  105.     }
  106. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top