Advertisement
Guest User

Main

a guest
Mar 26th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 82.21 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using System.Windows.Forms;
  5. using System.Speech.Synthesis;
  6. using System.Speech.Recognition;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Threading;
  10. using System.Runtime.InteropServices;
  11. using AudioSwitcher.AudioApi.CoreAudio;
  12. using System.Drawing;
  13. using System.Collections.Generic;
  14. using Microsoft.Win32;
  15. using System.Management.Automation.Runspaces;
  16. using System.Collections.ObjectModel;
  17. using System.Management.Automation;
  18. using System.Text;
  19.  
  20. //Alles was du sagst wiederholt Uny in diesen komischen Voice Pack was total real klingt von Marvin
  21.  
  22. namespace Uny
  23. {
  24.     public partial class Main : Form
  25.     {
  26.         public int atStat = 0;
  27.         public SpeechSynthesizer synthesizer = new SpeechSynthesizer();
  28.         public Choices list = new Choices();
  29.         public SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine();
  30.         public GrammarBuilder grammabuild = new GrammarBuilder();
  31.  
  32.         public SpeechSynthesizer synth = new SpeechSynthesizer();
  33.         public Choices seclist = new Choices();
  34.         public SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
  35.         public GrammarBuilder secgrammabuild = new GrammarBuilder();
  36.         acceptDiscordCall aDC = new acceptDiscordCall();
  37.         public Main()
  38.         {
  39.             ReadConfig();
  40.  
  41.             try
  42.             {
  43.  
  44.                 var KHK = File.ReadAllLines(System.AppDomain.CurrentDomain.BaseDirectory + @"languagePack.txt").ToArray();
  45.                 foreach (var line in KHK)
  46.                 {
  47.                     string eachLine = Convert.ToString(line);
  48.                     list.Add(eachLine);
  49.                 }
  50.             } catch (Exception exc)
  51.             {
  52.                 Console.WriteLine("Exception catched when loading languagePack! At line: -- {0}", exc);
  53.             }
  54.  
  55.             grammabuild.Append(list);
  56.  
  57.             Grammar gr = new Grammar(grammabuild);
  58.             try
  59.             {
  60.                 recognitionEngine.RequestRecognizerUpdate();
  61.                 recognitionEngine.LoadGrammarAsync(gr);
  62.                 recognitionEngine.SpeechRecognized += recognitionEngine_SpeechRecognized;
  63.                 recognitionEngine.SetInputToDefaultAudioDevice();
  64.                 recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
  65.             }
  66.             catch (Exception exc)
  67.             {
  68.                 Console.WriteLine("Exception catched -- {0}", exc);
  69.                 return;
  70.             }
  71.  
  72.             synthesizer.SelectVoiceByHints(VoiceGender.Female);
  73.             synthesizer.SpeakAsync("You ni activated");
  74.  
  75.             Console.ForegroundColor = ConsoleColor.Gray;
  76.             Console.WriteLine("Uny Protocol - Development Version " + curDevVersion);
  77.             Console.ForegroundColor = ConsoleColor.White;
  78.             Console.WriteLine(" ");
  79.  
  80.             string currentTime = DateTime.Now.ToString("hh:mm tt");
  81.             string textTime = DateTime.Now.ToString("hh:mm tt");
  82.             Console.ForegroundColor = ConsoleColor.Cyan;
  83.             Console.WriteLine("Current Time: " + textTime);
  84.             Console.ForegroundColor = ConsoleColor.White;
  85.  
  86.             Console.WriteLine(" ");
  87.  
  88.             if (currentTime.Contains("AM") == true)
  89.             {
  90.                 say("good morning user!");
  91.             }
  92.             else if (currentTime.Contains("01:") == true || currentTime.Contains("02:") == true && currentTime.Contains("PM") == true)
  93.             {
  94.                 say("good afternoon user!");
  95.             }
  96.             else if (currentTime.Contains("03:") == true || currentTime.Contains("04:") == true && currentTime.Contains("PM") == true)
  97.             {
  98.                 say("good afternoon user!");
  99.             }
  100.             else if (currentTime.Contains("05:") == true && currentTime.Contains("PM") == true)
  101.             {
  102.                 say("good afternoon user!");
  103.             }
  104.             else if (currentTime.Contains("06:") == true || currentTime.Contains("07:") && currentTime.Contains("PM") == true)
  105.             {
  106.                 say("good evening user!");
  107.             }
  108.             else if (currentTime.Contains("08:") == true || currentTime.Contains("09:") && currentTime.Contains("PM") == true)
  109.             {
  110.                 say("good evening user!");
  111.             }
  112.             else if (currentTime.Contains("10:") == true || currentTime.Contains("11:") && currentTime.Contains("PM") == true)
  113.             {
  114.                 say("good evening user!");
  115.             }
  116.             else if (currentTime.Contains("12:") == true && currentTime.Contains("AM") == true)
  117.             {
  118.                 say("good evening user!");
  119.             }
  120.             else if (currentTime.Contains("12:") == true && currentTime.Contains("PM") == true)
  121.             {
  122.                 say("good afternoon user!");
  123.             }
  124.  
  125.             string[] localPathRead = System.IO.File.ReadAllLines(System.AppDomain.CurrentDomain.BaseDirectory + @"Config.txt");
  126.             foreach(string line in localPathRead)
  127.             {
  128.                 if(line.Contains("local@") == true)
  129.                 {
  130.                     localPath = line.Split(Convert.ToChar("@")).Last();
  131.                 }
  132.             }
  133.  
  134.             InitializeComponent();
  135.             panel1.Width = 0;
  136.  
  137.             staticDeactivated = Uny.Properties.Resources.Uny_Slider_one;
  138.             staticActivated = Uny.Properties.Resources.Uny_Slider_two;
  139.             movingToActivated = Uny.Properties.Resources.activating_gif;
  140.             movingToDeactivated = Uny.Properties.Resources.deactivating_gif;
  141.  
  142.             pictureBox5.Image = staticDeactivated;
  143.  
  144.             label6.Visible = false;
  145.             label7.Visible = false;
  146.             label8.Visible = false;
  147.  
  148.             panel4.Visible = false;
  149.             inWork.Visible = false;
  150.             textBox1.Visible = false;
  151.             usernameLabel.Visible = false;
  152.  
  153.             Console.ForegroundColor = ConsoleColor.Red;
  154.             Console.WriteLine("Uny activated");
  155.             Console.ForegroundColor = ConsoleColor.White;
  156.             Console.WriteLine(" ");
  157.  
  158.             Console.WriteLine("------------------------------------------------");
  159.             Console.WriteLine(" ");
  160.  
  161.             string[] cc1 = File.ReadAllLines(localPath + @"Config.txt");
  162.  
  163.             foreach (string v in cc1)
  164.             {
  165.                 if (v.Contains("CC1@exist") == true)
  166.                 {
  167.                     existCC1 = 1;
  168.                     Console.WriteLine("Custom Command 1 exists!");
  169.                 }
  170.                 if (v.Contains("CC1type@") == true)
  171.                 {
  172.                     typeCC1 = v.Split(Convert.ToChar("@")).Last();
  173.                     Console.WriteLine("Type of Custom Command 1: " + typeCC1);
  174.                 }
  175.                 if (v.Contains("CC1action@") == true)
  176.                 {
  177.                     actionCC1 = v.Split(Convert.ToChar("@")).Last();
  178.                     Console.WriteLine("Action of Custom Command 1: " + actionCC1);
  179.                 }
  180.                 if (v.Contains("CC1call@") == true)
  181.                 {
  182.                     callCC1 = v.Split(Convert.ToChar("@")).Last();
  183.                     Console.WriteLine("Call of Custom Command 1: " + callCC1);
  184.                 }
  185.                 if(v.Contains("at@") == true)
  186.                 {
  187.                     if(v.Contains("1") == true)
  188.                     {
  189.                         button4.Text = "Turn off";
  190.                         atStat = 1;
  191.                     } else if(v.Contains("0") == true)
  192.                     {
  193.                         button4.Text = "Turn on";
  194.                     }
  195.                 }
  196.             }
  197.  
  198.             if(existCC1 == 1)
  199.             {
  200.                 button2.Text = "Custom Command 1 is active!";
  201.                 label6.Text = "type: " + typeCC1;
  202.                 label6.Visible = true;
  203.                 label7.Text = "call: " + callCC1;
  204.                 label7.Visible = true;
  205.                 label8.Text = "action: " + actionCC1;
  206.                 label8.Visible = true;
  207.             }
  208.  
  209.                 while (resultString == null)
  210.             {
  211.                 try
  212.                 {
  213.                     recognitionEngine.RequestRecognizerUpdate();
  214.                     recognitionEngine.LoadGrammarAsync(gr);
  215.                     recognitionEngine.SpeechRecognized += recognitionEngine_SpeechRecognized;
  216.                     recognitionEngine.SetInputToDefaultAudioDevice();
  217.                     recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
  218.                 }
  219.                 catch (Exception exc)
  220.                 {
  221.                     Console.WriteLine("Exception catched -- {0}", exc);
  222.                     Console.WriteLine("Make sure the microphone is being found!");
  223.                     return;
  224.                 }
  225.             }
  226.             label5.Text = "synchronizing data...";
  227.             label5.Visible = false;
  228.         }
  229.  
  230.         public string localPath = null;
  231.         private void label5_TextChanged(object sender, EventArgs e)
  232.         {
  233.             if (GEexist == 0 && UNexist == 0)
  234.             {
  235.                 Registration registration = new Registration();
  236.                 registration.ShowDialog();
  237.             }
  238.         }
  239.  
  240.         //CURRENT DEV VERSION
  241.         public string curDevVersion = "2.5";
  242.         //CURRENT DEV VERSION
  243.  
  244.         public int GEexist = 0;
  245.         public int UNexist = 0;
  246.  
  247.         public string eU;
  248.         public string eG;
  249.         public void ReadConfig()
  250.         {
  251.             string[] config = File.ReadAllLines(localPath + @"Config.txt");
  252.  
  253.             string UNisEmpty = "Username is empty!";
  254.             string GEisEmpty = "Gender is empty!";
  255.  
  256.             foreach (string r in config)
  257.             {
  258.                 if(r.Contains("UN@") == true)
  259.                 {
  260.                     try
  261.                     {
  262.                         string Username = r.Split(Convert.ToChar("@")).Last();
  263.  
  264.                         if(string.IsNullOrEmpty(Username) != true)
  265.                         {
  266.                             Console.WriteLine("First Line detected! -- {0}", Username);
  267.                             eU = Username;
  268.                             UNexist = 1;
  269.                         } else
  270.                         {
  271.                             Console.WriteLine("First Line detected! -- {0}", UNisEmpty);
  272.                         }
  273.  
  274.                     } catch (Exception exc)
  275.                     {
  276.                         Console.WriteLine("Exception catched at Line 179! -- {0}", exc);
  277.                     }
  278.                 }
  279.                 if(r.Contains("GE@") == true)
  280.                 {
  281.                     try
  282.                     {
  283.                         string Gender = r.Split(Convert.ToChar("@")).Last();
  284.  
  285.                         if(string.IsNullOrEmpty(Gender) != true)
  286.                         {
  287.                             Console.WriteLine("Second Line detected! -- {0}", Gender);
  288.                             if(Gender == "Female")
  289.                             {
  290.                                 eG = "Madame";
  291.                             } else if(Gender == "Male")
  292.                             {
  293.                                 eG = "Sir";
  294.                             }
  295.                             GEexist = 1;
  296.                         } else
  297.                         {
  298.                             Console.WriteLine("Second Line detected! -- {0}", GEisEmpty);
  299.                         }
  300.  
  301.                     } catch (Exception exc)
  302.                     {
  303.                         Console.WriteLine("Exception catched at Line 198! -- {0}", exc);
  304.                     }
  305.                 }
  306.             }
  307.         }
  308.         protected override void WndProc(ref Message m)
  309.         {
  310.             base.WndProc(ref m);
  311.             if (m.Msg == WM_NCHITTEST)
  312.                 m.Result = (IntPtr)(HT_CAPTION);
  313.         }
  314.  
  315.         private const int WM_NCHITTEST = 0x84;
  316.         private const int HT_CLIENT = 0x1;
  317.         private const int HT_CAPTION = 0x2;
  318.  
  319.         public string resultString = Convert.ToString(1);
  320.  
  321.         public const int KEYEVENTF_EXTENDKEY = 1;
  322.         public const int KEYEVENTF_KEYUP = 0;
  323.         public const int VK_MEDIA_NEXT_TRACK = 0xB0;
  324.         public const int VK_MEDIA_PLAY_PAUSE = 0xB3;
  325.         public const int VK_MEDIA_PREV_TRACK = 0xB1;
  326.  
  327.  
  328.  
  329.  
  330.  
  331.         [DllImport("user32.dll")]
  332.         public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo);
  333.  
  334.         [DllImport("User32.dll")]
  335.         static extern IntPtr GetForegroundWindow();
  336.  
  337.         [DllImport("User32.dll", SetLastError = true)]
  338.         static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint IpdwProcessId);
  339.  
  340.         [DllImport("USER32.DLL")]
  341.         public static extern Int32 SetForegroundWindow(int hWnd);
  342.  
  343.         [DllImport("User32.DLL", CharSet = CharSet.Unicode)]
  344.         public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
  345.  
  346.  
  347.  
  348.         public int discordVerified;
  349.         public string discordPath;
  350.  
  351.  
  352.         public void getDiscordProcess()
  353.         {
  354.             try
  355.             {
  356.                 Process[] processes = Process.GetProcessesByName("Discord");
  357.                 Process discord = processes[0];
  358.             }
  359.             catch
  360.             {
  361.                 Console.WriteLine("Discord was not found!");
  362.                 discordVerified = 0;
  363.             }
  364.         }
  365.         private Image staticDeactivated;
  366.         private Image staticActivated;
  367.         private Image movingToActivated;
  368.         private Image movingToDeactivated;
  369.  
  370.         public void say(String h)
  371.         {
  372.             synthesizer.SpeakAsync(h);
  373.         }
  374.  
  375.         public void listenNow()
  376.         {
  377.             var KHK = File.ReadAllLines(@"languagePack.txt").ToArray();
  378.             foreach (var line in KHK)
  379.             {
  380.                 string eachLine = Convert.ToString(line);
  381.                 seclist.Add(eachLine);
  382.             }
  383.             secgrammabuild.Append(seclist);
  384.  
  385.             Grammar gr = new Grammar(secgrammabuild);
  386.             try
  387.             {
  388.                 rec.RequestRecognizerUpdate();
  389.                 rec.LoadGrammarAsync(gr);
  390.                 rec.SpeechRecognized += recEngine_SpeechRecognized;
  391.                 rec.SetInputToDefaultAudioDevice();
  392.                 rec.RecognizeAsync(RecognizeMode.Multiple);
  393.             }
  394.             catch
  395.             {
  396.                 return;
  397.             }
  398.         }
  399.         private string runScript(string script)
  400.         {
  401.             Runspace runspace = RunspaceFactory.CreateRunspace();
  402.             runspace.Open();
  403.             Pipeline pipeline = runspace.CreatePipeline();
  404.             pipeline.Commands.AddScript(script);
  405.             pipeline.Commands.Add("Out-String");
  406.             Collection<PSObject> results = pipeline.Invoke();
  407.             runspace.Close();
  408.             StringBuilder sb = new StringBuilder();
  409.             foreach (PSObject ps in results)
  410.             {
  411.                 sb.AppendLine(ps.ToString());
  412.             }
  413.             return sb.ToString();
  414.         }
  415.  
  416.         public string mainListenString;
  417.  
  418.         public void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
  419.         {
  420.             String r = e.Result.Text;
  421.             mainListenString = r;
  422.         }
  423.  
  424.         public void eoc()
  425.         {
  426.             resultString = null;
  427.             mainListenString = null;
  428.  
  429.         }
  430.  
  431.         public ManualResetEvent waitForStringEvent = new ManualResetEvent(false);
  432.  
  433.         public string m;
  434.  
  435.         public CoreAudioDevice defaultPlaybackDevice = new CoreAudioController().DefaultPlaybackDevice;
  436.  
  437.         public void getCurrentVolume()
  438.         {
  439.             Console.ForegroundColor = ConsoleColor.Green;
  440.             Console.WriteLine("Current Volume:" + defaultPlaybackDevice.Volume);
  441.             Console.ForegroundColor = ConsoleColor.White;
  442.         }
  443.         public void cw(String t)
  444.         {
  445.             Console.WriteLine(t);
  446.         }
  447.  
  448.         private int FormActive = 1;
  449.  
  450.         public void cbg(String v)
  451.         {
  452.             if(eG == "Sir")
  453.             {
  454.                 say(v + "sir");
  455.             } else if (eG == "Madame")
  456.             {
  457.                 say(v + "madame");
  458.             }
  459.         }
  460.  
  461.         System.Windows.Forms.Timer v = null;
  462.         private void resetAwaitListen()
  463.         {
  464.             v = new System.Windows.Forms.Timer();
  465.             v.Interval = 5000;
  466.             v.Tick += new EventHandler(action);
  467.             v.Enabled = true;
  468.         }
  469.  
  470.         void action(object sender, EventArgs e)
  471.         {
  472.             awaitListen = false;
  473.         }
  474.  
  475.         public bool awaitListen = false;
  476.  
  477.         public async void recognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
  478.         {
  479.             String r = e.Result.Text;
  480.             resultString = null;
  481.             resultString = r;
  482.             Console.WriteLine("User: " + r);
  483.  
  484.             while (resultString != null)
  485.             {
  486.                 if (r == "hello uny" || r == "hey uny" && GEexist == 1 && UNexist == 1)
  487.                 {
  488.                     string greetingChoice = " ";
  489.                     Random random = new Random();
  490.                     int randomNumber = random.Next(0, 100);
  491.  
  492.                     if (randomNumber < 25)
  493.                     {
  494.                         greetingChoice = " ";
  495.  
  496.                         Console.Write("Uny: ");
  497.                         Console.ForegroundColor = ConsoleColor.DarkCyan;
  498.                         Console.WriteLine("listen sound");
  499.                         Console.ForegroundColor = ConsoleColor.White;
  500.                     }
  501.                     else if (randomNumber > 25 && randomNumber < 50)
  502.                     {
  503.                         greetingChoice = "Yes?";
  504.  
  505.                         Console.Write("Uny: ");
  506.                         Console.ForegroundColor = ConsoleColor.DarkCyan;
  507.                         Console.WriteLine("Yes?");
  508.                         Console.ForegroundColor = ConsoleColor.White;
  509.                         listenSound();
  510.                     }
  511.                     else if (randomNumber > 50 && randomNumber < 75)
  512.                     {
  513.                         greetingChoice = " ";
  514.  
  515.                         Console.Write("Uny: ");
  516.                         Console.ForegroundColor = ConsoleColor.DarkCyan;
  517.                         Console.WriteLine("listen sound");
  518.                         Console.ForegroundColor = ConsoleColor.White;
  519.                     }
  520.                     else if (randomNumber > 75)
  521.                     {
  522.                         greetingChoice = "How can I help you " + eG;
  523.  
  524.                         Console.Write("Uny: ");
  525.                         Console.ForegroundColor = ConsoleColor.DarkCyan;
  526.                         Console.WriteLine("How can I help you " + eG + "?");
  527.                         Console.ForegroundColor = ConsoleColor.White;
  528.                     }
  529.  
  530.                     if (greetingChoice == " ")
  531.                     {
  532.                         listenSound();
  533.                     } else
  534.                     {
  535.                         say(greetingChoice);
  536.                     }
  537.  
  538.                     listenNow();
  539.                     if(randomNumber > 75)
  540.                     {
  541.                         await Task.Delay(6000);
  542.                     } else
  543.                     {
  544.                         await Task.Delay(4000);
  545.                     }
  546.                     m = mainListenString;
  547.  
  548.                     awaitListen = true;
  549.                     resetAwaitListen();
  550.                     while (awaitListen == true)
  551.                     {
  552.                         while (!string.IsNullOrEmpty(m))
  553.                         {
  554.                             if (existCC1 == 1)
  555.                             {
  556.                                 if (m == callCC1)
  557.                                 {
  558.                                     if (typeCC1 == "respond")
  559.                                     {
  560.                                         say(actionCC1);
  561.                                         Console.WriteLine("Uny: " + actionCC1);
  562.                                         if (LogStatus == 1)
  563.                                         {
  564.                                             richTextBox1.AppendText("User: " + m + Environment.NewLine);
  565.                                             richTextBox1.AppendText("Uny: " + actionCC1 + Environment.NewLine);
  566.                                         }
  567.  
  568.                                         await Task.Delay(5000);
  569.                                         r = null;
  570.                                         eoc();
  571.                                         return;
  572.                                     }
  573.                                     else if (typeCC1 == "open tab")
  574.                                     {
  575.                                         Process.Start("chrome.exe", actionCC1);
  576.                                         dS();
  577.                                         Console.WriteLine("Engine: Opening " + actionCC1);
  578.                                         if (LogStatus == 1)
  579.                                         {
  580.                                             richTextBox1.AppendText("User: " + m + Environment.NewLine);
  581.                                             richTextBox1.AppendText("Engine: Opening " + actionCC1 + Environment.NewLine);
  582.                                         }
  583.  
  584.                                         await Task.Delay(5000);
  585.                                         r = null;
  586.                                         eoc();
  587.                                         return;
  588.                                     }
  589.                                 }
  590.                             }
  591.  
  592.                             if(m == "open calculator" || m == "open the calculator")
  593.                             {
  594.                                 Process.Start("calc.exe");
  595.                                 dS();
  596.                                 Console.WriteLine("Engine: Starting calculator app!");
  597.                                 Console.WriteLine("Uny: *done sound*");
  598.                                 if (LogStatus == 1)
  599.                                 {
  600.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  601.                                     richTextBox1.AppendText("Engine: Starting calculator app!");
  602.                                 }
  603.  
  604.                                 await Task.Delay(3000);
  605.                                 r = null;
  606.                                 eoc();
  607.                                 return;
  608.                             }
  609.                             if (m == "open the explorer")
  610.                             {
  611.                                 dS();
  612.                                 Process.Start("explorer.exe");
  613.                                 Console.WriteLine("Uny: *done sound*");
  614.                                 if (LogStatus == 1)
  615.                                 {
  616.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  617.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  618.                                 }
  619.                                 await Task.Delay(5000);
  620.                                 r = null;
  621.                                 eoc();
  622.                                 return;
  623.                             }
  624.  
  625.                             if (m == "open youtube")
  626.                             {
  627.                                 dS();
  628.                                 Process.Start("chrome.exe", "http://youtube.com");
  629.                                 cw("Uny: *done sound*");
  630.                                 if (LogStatus == 1)
  631.                                 {
  632.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  633.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  634.                                 }
  635.                                 await Task.Delay(5000);
  636.  
  637.                                 r = null;
  638.                                 eoc();
  639.                                 return;
  640.                             }
  641.  
  642.                             if (m == "nevermind" || m == "nothing" || m == "forget about it" || m == "forget it")
  643.                             {
  644.                                 dS();
  645.                                 Console.WriteLine("Uny: *done sound*");
  646.                                 if (LogStatus == 1)
  647.                                 {
  648.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  649.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  650.                                 }
  651.                                 await Task.Delay(3000);
  652.                                 r = null;
  653.                                 eoc();
  654.                                 return;
  655.                             }
  656.  
  657.                             if (m == "open panel" || m == "open options")
  658.                             {
  659.                                 if (panel1.Width == 0)
  660.                                 {
  661.                                     dS();
  662.  
  663.                                     Console.ForegroundColor = ConsoleColor.Magenta;
  664.                                     cw("Opening panel!");
  665.                                     Console.ForegroundColor = ConsoleColor.White;
  666.                                     cw("Uny: *done sound*");
  667.                                     if (LogStatus == 1)
  668.                                     {
  669.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  670.                                         richTextBox1.AppendText("Engine: Opening panel!" + Environment.NewLine);
  671.                                         richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  672.                                     }
  673.  
  674.                                     usernameLabel.Visible = true;
  675.                                     textBox1.Visible = true;
  676.  
  677.                                     panel1.Width = 1;
  678.                                     panel2.Width = 1;
  679.                                     await Task.Delay(50);
  680.                                     panel1.Width = 50;
  681.                                     panel2.Width = 50;
  682.                                     await Task.Delay(50);
  683.                                     panel1.Width = 100;
  684.                                     panel2.Width = 100;
  685.                                     await Task.Delay(50);
  686.                                     panel1.Width = 150;
  687.                                     panel2.Width = 150;
  688.                                     await Task.Delay(50);
  689.                                     panel1.Width = 200;
  690.                                     panel2.Width = 200;
  691.                                     await Task.Delay(50);
  692.                                     panel1.Width = 250;
  693.                                     panel2.Width = 250;
  694.                                     await Task.Delay(50);
  695.                                     panel1.Width = 300;
  696.                                     panel2.Width = 300;
  697.  
  698.                                 }
  699.                                 else
  700.                                 {
  701.                                     say("Option panel is already open!");
  702.                                     if (LogStatus == 1)
  703.                                     {
  704.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  705.                                         richTextBox1.AppendText("Uny: Option panel is already open!" + Environment.NewLine);
  706.                                     }
  707.                                 }
  708.  
  709.                                 r = null;
  710.                                 eoc();
  711.                                 return;
  712.                             }
  713.                             if (m == "close panel" || m == "close options")
  714.                             {
  715.                                 if (panel1.Width == 300)
  716.                                 {
  717.                                     dS();
  718.  
  719.                                     Console.ForegroundColor = ConsoleColor.Magenta;
  720.                                     cw("Closing panel!");
  721.                                     Console.ForegroundColor = ConsoleColor.White;
  722.                                     cw("Uny: *done sound*");
  723.                                     if (LogStatus == 1)
  724.                                     {
  725.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  726.                                         richTextBox1.AppendText("Engine: Closing Panel!" + Environment.NewLine);
  727.                                         richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  728.                                     }
  729.  
  730.                                     panel1.Width = 300;
  731.                                     panel2.Width = 300;
  732.                                     await Task.Delay(50);
  733.                                     panel1.Width = 250;
  734.                                     panel2.Width = 250;
  735.                                     await Task.Delay(50);
  736.                                     panel1.Width = 200;
  737.                                     panel2.Width = 200;
  738.                                     await Task.Delay(50);
  739.                                     panel1.Width = 150;
  740.                                     panel2.Width = 150;
  741.                                     await Task.Delay(50);
  742.                                     panel1.Width = 100;
  743.                                     panel2.Width = 100;
  744.                                     await Task.Delay(50);
  745.                                     panel1.Width = 50;
  746.                                     panel2.Width = 50;
  747.                                     await Task.Delay(50);
  748.                                     panel1.Width = 0;
  749.                                     panel2.Width = 0;
  750.  
  751.                                     usernameLabel.Visible = false;
  752.                                     textBox1.Visible = false;
  753.                                 }
  754.                                 else
  755.                                 {
  756.                                     say("Option panel is already closed!");
  757.                                     if (LogStatus == 1)
  758.                                     {
  759.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  760.                                         richTextBox1.AppendText("Uny: Option Panel is already closed!" + Environment.NewLine);
  761.                                     }
  762.                                 }
  763.  
  764.                                 r = null;
  765.                                 eoc();
  766.                                 return;
  767.                             }
  768.                             if (m == "open twitch")
  769.                             {
  770.                                 dS();
  771.                                 Process.Start("chrome.exe", "https://www.twitch.tv/");
  772.                                 cw("Uny: *done sound*");
  773.                                 if (LogStatus == 1)
  774.                                 {
  775.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  776.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  777.                                 }
  778.                                 await Task.Delay(5000);
  779.  
  780.                                 r = null;
  781.                                 eoc();
  782.                                 return;
  783.                             }
  784.                             if(m == "network scan")
  785.                             {
  786.                                 dS();
  787.                                 if(LogStatus == 1)
  788.                                 {
  789.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  790.                                     say("Scanning the local network, this might take a while");
  791.                                     richTextBox1.AppendText("Uny: " + runScript("1..254 | ForEach-Object {Test-Connection -ComputerName \"192.168.0.$_\" -Count 1 -ErrorAction SilentlyContinue}"));
  792.                                     say("Scan is done, you can now see the result in the log section");
  793.                                 } else
  794.                                 {
  795.                                     say("Log panel must be activated to use network functions");
  796. ;                               }
  797.                                 await Task.Delay(3000);
  798.  
  799.                                 r = null;
  800.                                 eoc();
  801.                                 return;
  802.                             }
  803.  
  804.                             if (m == "end your process")
  805.                             {
  806.                                 say("Thank you for using me " + eG);
  807.                                 if (LogStatus == 1)
  808.                                 {
  809.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  810.                                     richTextBox1.AppendText("Uny: Thank you for using me, " + eG + "!" + Environment.NewLine);
  811.                                 }
  812.                                 await Task.Delay(5000);
  813.                                 Application.Exit();
  814.                             }
  815.  
  816.                             if (m == "goodbye")
  817.                             {
  818.                                 say("Goodbye user, it was nice serving you " + eU);
  819.                                 Console.WriteLine("Uny: Goodbye " + eG + ", it was nice serving you " + eU + "!");
  820.                                 if (LogStatus == 1)
  821.                                 {
  822.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  823.                                     richTextBox1.AppendText("Uny: Goodbye " + eG + ", it was nice serving you " + eU + "!" + Environment.NewLine);
  824.                                 }
  825.                                 await Task.Delay(5000);
  826.                                 r = null;
  827.                                 eoc();
  828.                                 return;
  829.                             }
  830.  
  831.                             if (m == "pause" || m == "pause the music" || m == "play" || m == "play the music" || m == "play music" || m == "pause music" || m == "stop the music" || m == "stop")
  832.                             {
  833.                                 dS();
  834.                                 keybd_event(VK_MEDIA_PLAY_PAUSE, 0, KEYEVENTF_EXTENDKEY, IntPtr.Zero);
  835.                                 Console.WriteLine("Uny: *done sound*");
  836.                                 if (LogStatus == 1)
  837.                                 {
  838.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  839.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  840.                                 }
  841.                                 await Task.Delay(3000);
  842.                                 r = null;
  843.                                 eoc();
  844.                                 return;
  845.                             }
  846.  
  847.                             if (m == "next" || m == "next track" || m == "skip" || m == "skip track")
  848.                             {
  849.                                 dS();
  850.                                 keybd_event(VK_MEDIA_NEXT_TRACK, 0, KEYEVENTF_EXTENDKEY, IntPtr.Zero);
  851.                                 Console.WriteLine("Uny: *done sound*");
  852.                                 if (LogStatus == 1)
  853.                                 {
  854.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  855.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  856.                                 }
  857.                                 await Task.Delay(3000);
  858.                                 r = null;
  859.                                 eoc();
  860.                                 return;
  861.                             }
  862.  
  863.                             if (m == "show ui" || m == "show the ui" || m == "open the ui" || m == "open ui")
  864.                             {
  865.                                 if (FormActive == 0)
  866.                                 {
  867.                                     dS();
  868.                                     this.Show();
  869.  
  870.                                     Console.ForegroundColor = ConsoleColor.Magenta;
  871.                                     cw("Activating Uny UI");
  872.                                     Console.ForegroundColor = ConsoleColor.White;
  873.                                     if (LogStatus == 1)
  874.                                     {
  875.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  876.                                         richTextBox1.AppendText("Engine: Activating Uny UI" + Environment.NewLine);
  877.                                         richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  878.                                     }
  879.                                     await Task.Delay(3000);
  880.  
  881.                                     cw("Uny: *done sound*");
  882.                                 }
  883.                                 else
  884.                                 {
  885.                                     say("The interface is already open!");
  886.                                     if (LogStatus == 1)
  887.                                     {
  888.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  889.                                         richTextBox1.AppendText("Uny: The interface is already open!" + Environment.NewLine);
  890.                                     }
  891.                                 }
  892.  
  893.                                 r = null;
  894.                                 eoc();
  895.                                 return;
  896.                             }
  897.  
  898.                             if (m == "hide ui" || m == "hide the ui" || m == "hide the interface" || m == "hide interface" || m == "minimize the interface" || m == "minimize interface")
  899.                             {
  900.                                 if (FormActive == 1)
  901.                                 {
  902.                                     dS();
  903.                                     this.Hide();
  904.  
  905.                                     Console.ForegroundColor = ConsoleColor.Magenta;
  906.                                     cw("Hiding Uny UI");
  907.                                     Console.ForegroundColor = ConsoleColor.White;
  908.                                     if (LogStatus == 1)
  909.                                     {
  910.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  911.                                         richTextBox1.AppendText("Engine: Hiding Uny UI!" + Environment.NewLine);
  912.                                         richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  913.                                     }
  914.                                     FormActive = 0;
  915.                                     await Task.Delay(3000);
  916.  
  917.                                     cw("Uny: *done sound*");
  918.                                 }
  919.                                 else
  920.                                 {
  921.                                     say("The interface is already hidden!");
  922.                                     if (LogStatus == 1)
  923.                                     {
  924.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  925.                                         richTextBox1.AppendText("Uny: The interface is already hidden!" + Environment.NewLine);
  926.                                     }
  927.                                 }
  928.  
  929.                                 r = null;
  930.                                 eoc();
  931.                                 return;
  932.                             }
  933.                             if (m == "last track" || m == "last")
  934.                             {
  935.                                 dS();
  936.                                 keybd_event(VK_MEDIA_PREV_TRACK, 0, KEYEVENTF_EXTENDKEY, IntPtr.Zero);
  937.                                 Console.WriteLine("Uny: *done sound*");
  938.                                 if (LogStatus == 1)
  939.                                 {
  940.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  941.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  942.                                 }
  943.                                 await Task.Delay(4000);
  944.                                 r = null;
  945.                                 eoc();
  946.                                 return;
  947.                             }
  948.  
  949.                             if (m == "lower system volume by fifty percent" || m == "lower volume by fifty percent")
  950.                             {
  951.                                 say("lowering system volume by 50 percent");
  952.                                 dS();
  953.                                 getCurrentVolume();
  954.  
  955.                                 cw("Uny: Lowering system volume by 50%!");
  956.                                 if (LogStatus == 1)
  957.                                 {
  958.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  959.                                     richTextBox1.AppendText("Uny: Lowering system volume by 50%" + Environment.NewLine);
  960.                                 }
  961.  
  962.                                 double curVol = defaultPlaybackDevice.Volume;
  963.                                 double newVol = curVol - 50;
  964.                                 defaultPlaybackDevice.Volume = newVol;
  965.  
  966.                                 await Task.Delay(5000);
  967.                                 r = null;
  968.                                 eoc();
  969.                                 return;
  970.                             }
  971.  
  972.                             if (m == "higher system volume by fifty percent" || m == "raise volume by fifty percent" || m == "higher volume by fifty percent")
  973.                             {
  974.                                 say("highering system volume by 50 percent");
  975.                                 dS();
  976.                                 getCurrentVolume();
  977.  
  978.                                 cw("Uny: Lowering system volume by 50%!");
  979.                                 if (LogStatus == 1)
  980.                                 {
  981.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  982.                                     richTextBox1.AppendText("Uny: Lowering system volume by 50%!" + Environment.NewLine);
  983.                                 }
  984.  
  985.                                 double curVol = defaultPlaybackDevice.Volume;
  986.                                 double newVol = curVol + 50;
  987.                                 defaultPlaybackDevice.Volume = newVol;
  988.  
  989.                                 await Task.Delay(5000);
  990.                                 r = null;
  991.                                 eoc();
  992.                                 return;
  993.                             }
  994.  
  995.                             if (m == "lower system volume by twentyfive percent" || m == "lower volume by twentyfive percent")
  996.                             {
  997.                                 say("lowering system volume by 25 percent");
  998.                                 dS();
  999.                                 getCurrentVolume();
  1000.  
  1001.                                 cw("Uny: Lowering system volume by 25%!");
  1002.                                 if (LogStatus == 1)
  1003.                                 {
  1004.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1005.                                     richTextBox1.AppendText("Uny: Lowering system volume by 25%!" + Environment.NewLine);
  1006.                                 }
  1007.  
  1008.                                 double curVol = defaultPlaybackDevice.Volume;
  1009.                                 double newVol = curVol - 25;
  1010.                                 defaultPlaybackDevice.Volume = newVol;
  1011.  
  1012.                                 await Task.Delay(5000);
  1013.                                 r = null;
  1014.                                 eoc();
  1015.                                 return;
  1016.                             }
  1017.  
  1018.                             if (m == "higher system volume by twentyfive percent" || m == "raise volume by twentyfive percent" || m == "higher volume by twentyfive percent")
  1019.                             {
  1020.                                 say("highering system volume by 25 percent");
  1021.                                 dS();
  1022.                                 getCurrentVolume();
  1023.  
  1024.                                 cw("Uny: Highering system volume by 25%!");
  1025.                                 if (LogStatus == 1)
  1026.                                 {
  1027.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1028.                                     richTextBox1.AppendText("Uny: Highering system volume by 25%!" + Environment.NewLine);
  1029.                                 }
  1030.  
  1031.                                 double curVol = defaultPlaybackDevice.Volume;
  1032.                                 double newVol = curVol + 25;
  1033.                                 defaultPlaybackDevice.Volume = newVol;
  1034.  
  1035.                                 await Task.Delay(5000);
  1036.                                 r = null;
  1037.                                 eoc();
  1038.                                 return;
  1039.                             }
  1040.  
  1041.                             if (m == "lower system volume by five percent" || m == "lower volume by five percent")
  1042.                             {
  1043.                                 say("lowering system volume by 5 percent");
  1044.                                 dS();
  1045.                                 getCurrentVolume();
  1046.  
  1047.                                 cw("Uny: Lowering system volume by 5%!");
  1048.                                 if (LogStatus == 1)
  1049.                                 {
  1050.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1051.                                     richTextBox1.AppendText("Uny: Lowering system volume by 5%!" + Environment.NewLine);
  1052.                                 }
  1053.  
  1054.                                 double curVol = defaultPlaybackDevice.Volume;
  1055.                                 double newVol = curVol - 5;
  1056.                                 defaultPlaybackDevice.Volume = newVol;
  1057.  
  1058.                                 await Task.Delay(5000);
  1059.                                 r = null;
  1060.                                 eoc();
  1061.                                 return;
  1062.                             }
  1063.  
  1064.                             if (m == "higher system volume by five percent" || m == "raise volume by five percent" || m == "higher volume by five percent")
  1065.                             {
  1066.                                 say("highering system volume by 5 percent");
  1067.                                 dS();
  1068.                                 getCurrentVolume();
  1069.  
  1070.                                 cw("Uny: Highering system volume by 5%!");
  1071.                                 if (LogStatus == 1)
  1072.                                 {
  1073.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1074.                                     richTextBox1.AppendText("Uny: Highering system volume by 5%!" + Environment.NewLine);
  1075.                                 }
  1076.  
  1077.                                 double curVol = defaultPlaybackDevice.Volume;
  1078.                                 double newVol = curVol + 5;
  1079.                                 defaultPlaybackDevice.Volume = newVol;
  1080.  
  1081.                                 await Task.Delay(5000);
  1082.                                 r = null;
  1083.                                 eoc();
  1084.                                 return;
  1085.                             }
  1086.  
  1087.                             if (m == "set system volume to fifty percent" || m == "set volume to fifty percent")
  1088.                             {
  1089.                                 say("Setting system volume to 50 percent!");
  1090.                                 dS();
  1091.                                 getCurrentVolume();
  1092.                                 cw("Setting system volume to 50%!");
  1093.                                 if (LogStatus == 1)
  1094.                                 {
  1095.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1096.                                     richTextBox1.AppendText("Uny: Setting system volume to 50%!" + Environment.NewLine);
  1097.                                 }
  1098.  
  1099.                                 defaultPlaybackDevice.Volume = 50;
  1100.                                 await Task.Delay(4000);
  1101.                                 r = null;
  1102.                                 eoc();
  1103.                                 return;
  1104.                             }
  1105.  
  1106.                             if (m == "set system volume to onehundered percent" || m == "set volume to onehundered percent")
  1107.                             {
  1108.                                 say("Setting system volume to 100 percent!");
  1109.                                 dS();
  1110.                                 getCurrentVolume();
  1111.                                 cw("Setting system volume to 100%!");
  1112.  
  1113.                                 if (LogStatus == 1)
  1114.                                 {
  1115.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1116.                                     richTextBox1.AppendText("Uny: Setting system volume to 100%!" + Environment.NewLine);
  1117.                                 }
  1118.  
  1119.                                 defaultPlaybackDevice.Volume = 100;
  1120.                                 await Task.Delay(4000);
  1121.                                 r = null;
  1122.                                 eoc();
  1123.                                 return;
  1124.                             }
  1125.  
  1126.                             if (m == "shutdown")
  1127.                             {
  1128.                                 say("okay, i will shutdown now, goodbye " + eU);
  1129.                                 System.Console.WriteLine("Uny: Okay, I will shutdown now, goodbye " + eU + "!");
  1130.                                 if (LogStatus == 1)
  1131.                                 {
  1132.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1133.                                     richTextBox1.AppendText("Uny: Okay, I will shutdown now, goodbye " + eU + "!" + Environment.NewLine);
  1134.                                 }
  1135.                                 await Task.Delay(5000);
  1136.                                 Application.Exit();
  1137.                             }
  1138.  
  1139.                             if (m == "accept call")
  1140.                             {
  1141.                                 getDiscordProcess();
  1142.                                 await Task.Delay(2000);
  1143.                                 Console.WriteLine(discordPath);
  1144.  
  1145.                                 if (discordVerified == 1)
  1146.                                 {
  1147.                                     dS();
  1148.                                     Console.Write("Uny: ");
  1149.  
  1150.                                     Console.ForegroundColor = ConsoleColor.Red;
  1151.                                     Console.WriteLine("Accepting discord call!");
  1152.                                     Console.ForegroundColor = ConsoleColor.White;
  1153.  
  1154.                                     if (LogStatus == 1)
  1155.                                     {
  1156.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1157.                                         richTextBox1.AppendText("Engine: Accepting discord call!" + Environment.NewLine);
  1158.                                         richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  1159.                                     }
  1160.  
  1161.                                     await Task.Delay(2000);
  1162.                                     SendKeys.Send("^({Enter})");
  1163.                                 }
  1164.                                 else
  1165.                                 {
  1166.                                     say("discord was not found on your pc!");
  1167.                                     Console.Write("Uny: ");
  1168.  
  1169.                                     Console.ForegroundColor = ConsoleColor.Red;
  1170.                                     cw("Discord was not found on your PC!");
  1171.                                     Console.ForegroundColor = ConsoleColor.White;
  1172.                                     if (LogStatus == 1)
  1173.                                     {
  1174.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1175.                                         richTextBox1.AppendText("Engine: FATAL ERROR, could not find Discord on your PC!");
  1176.                                         richTextBox1.AppendText("Uny: Discord was not found on your PC!" + Environment.NewLine);
  1177.                                     }
  1178.                                     await Task.Delay(3000);
  1179.                                 }
  1180.                                 r = null;
  1181.                                 eoc();
  1182.                                 return;
  1183.                             }
  1184.  
  1185.                             if (m == "open discord" || m == "start discord" || m == "launch discord")
  1186.                             {
  1187.                                 getDiscordProcess();
  1188.                                 if (discordVerified == 1)
  1189.                                 {
  1190.                                     dS();
  1191.                                     Console.ForegroundColor = ConsoleColor.Red;
  1192.                                     cw("Starting Discord process!");
  1193.                                     Console.ForegroundColor = ConsoleColor.White;
  1194.  
  1195.                                     Console.Write("Uny: ");
  1196.                                     Console.WriteLine("*done sound*");
  1197.                                     if (LogStatus == 1)
  1198.                                     {
  1199.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1200.                                         richTextBox1.AppendText("Engine: Starting Discord process!" + Environment.NewLine);
  1201.                                         richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  1202.                                     }
  1203.                                 }
  1204.                                 else
  1205.                                 {
  1206.                                     say("I could not find discord on your pc!");
  1207.                                     Console.Write("Uny: ");
  1208.  
  1209.                                     Console.ForegroundColor = ConsoleColor.Red;
  1210.                                     cw("Discord was not found on your PC!");
  1211.                                     Console.ForegroundColor = ConsoleColor.White;
  1212.                                     if (LogStatus == 1)
  1213.                                     {
  1214.                                         richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1215.                                         richTextBox1.AppendText("Engine: FATAL ERROR, could not find Discord on your PC!" + Environment.NewLine);
  1216.                                         richTextBox1.AppendText("Uny: I could not find Discord on your PC!" + Environment.NewLine);
  1217.                                     }
  1218.                                     await Task.Delay(3000);
  1219.                                 }
  1220.                                 r = null;
  1221.                                 eoc();
  1222.                                 return;
  1223.                             }
  1224.  
  1225.                             if (m == "can you open chrome" || m == "may you open chrome" || m == "open chrome")
  1226.                             {
  1227.                                 Process.Start("chrome.exe", "http://google.com");
  1228.                                 dS();
  1229.                                 Console.WriteLine("Uny: *done sound*");
  1230.                                 if (LogStatus == 1)
  1231.                                 {
  1232.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1233.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  1234.                                 }
  1235.                                 await Task.Delay(5000);
  1236.                                 r = null;
  1237.                                 eoc();
  1238.                                 return;
  1239.                             }
  1240.  
  1241.                             if (m == "how are you")
  1242.                             {
  1243.                                 say("i am good, thanks for asking!");
  1244.                                 Console.WriteLine("Uny: I am good, thanks for asking!");
  1245.                                 if (LogStatus == 1)
  1246.                                 {
  1247.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1248.                                     richTextBox1.AppendText("Engine: Why are you even asking that? It is a machine, it has no feelings lol" + Environment.NewLine);
  1249.                                     richTextBox1.AppendText("Uny: I am good, thanks for asking!" + Environment.NewLine);
  1250.                                 }
  1251.                                 await Task.Delay(5000);
  1252.                                 r = null;
  1253.                                 eoc();
  1254.                                 return;
  1255.                             }
  1256.  
  1257.                             if (m == "thank you")
  1258.                             {
  1259.                                 say("no problems, i am made for serving!");
  1260.                                 Console.WriteLine("Uny: No problems, I am made for serving!");
  1261.                                 if (LogStatus == 1)
  1262.                                 {
  1263.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1264.                                     richTextBox1.AppendText("Uny: No problems, I am made for serving!" + Environment.NewLine);
  1265.                                 }
  1266.                                 await Task.Delay(5000);
  1267.                                 r = null;
  1268.                                 eoc();
  1269.                                 return;
  1270.                             }
  1271.  
  1272.                             if (m == "i am back")
  1273.                             {
  1274.                                 say("welcome back " + eU + "!");
  1275.                                 Console.WriteLine("Uny: Welcome back " + eU + "!");
  1276.                                 if (LogStatus == 1)
  1277.                                 {
  1278.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1279.                                     richTextBox1.AppendText("Uny: Welcome back " + eU + "!" + Environment.NewLine);
  1280.                                 }
  1281.                                 await Task.Delay(5000);
  1282.                                 r = null;
  1283.                                 eoc();
  1284.                                 return;
  1285.                             }
  1286.  
  1287.                             if (m == "you are really helpful")
  1288.                             {
  1289.                                 say("thank you, I am doing my best to make your life easier!");
  1290.                                 Console.WriteLine("Uny: thank you, I am doing my best to make your life easier!");
  1291.                                 if (LogStatus == 1)
  1292.                                 {
  1293.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1294.                                     richTextBox1.AppendText("Uny: Thank you, I am doing my best to make your life easier!" + Environment.NewLine);
  1295.                                 }
  1296.                                 await Task.Delay(5000);
  1297.                                 r = null;
  1298.                                 eoc();
  1299.                                 return;
  1300.                             }
  1301.  
  1302.                             if (m == "what time is it")
  1303.                             {
  1304.                                 say("It is " + DateTime.Now.ToString("hh:mm tt"));
  1305.                                 Console.WriteLine("Uny: It is " + DateTime.Now.ToString("hh:mm tt"));
  1306.                                 if (LogStatus == 1)
  1307.                                 {
  1308.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1309.                                     richTextBox1.AppendText("Uny: It is " + DateTime.Now.ToString("hh:mm tt") + Environment.NewLine);
  1310.                                 }
  1311.                                 await Task.Delay(5000);
  1312.                                 r = null;
  1313.                                 eoc();
  1314.                                 return;
  1315.                             }
  1316.  
  1317.                             if (m == "who created you")
  1318.                             {
  1319.                                 say("cresk and lua created me!");
  1320.                                 Console.WriteLine("Uny: Cresk and Lua created me!");
  1321.                                 if (LogStatus == 1)
  1322.                                 {
  1323.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1324.                                     richTextBox1.AppendText("Uny: Cresk and Lua created me!" + Environment.NewLine);
  1325.                                 }
  1326.                                 await Task.Delay(5000);
  1327.                                 r = null;
  1328.                                 eoc();
  1329.                                 return;
  1330.                             }
  1331.  
  1332.                             if (m == "open chrome")
  1333.                             {
  1334.                                 say("ofcourse!");
  1335.                                 Process.Start("chrome.exe", "http://google.com");
  1336.                                 dS();
  1337.                                 Console.WriteLine("Uny: Ofcourse!");
  1338.                                 if (LogStatus == 1)
  1339.                                 {
  1340.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1341.                                     richTextBox1.AppendText("Uny: Of course!" + Environment.NewLine);
  1342.                                 }
  1343.                                 await Task.Delay(5000);
  1344.                                 r = null;
  1345.                                 eoc();
  1346.                                 return;
  1347.                             }
  1348.  
  1349.                             if (m == "good morning")
  1350.                             {
  1351.                                 say("good morning " + eG);
  1352.                                 Console.WriteLine("Uny: Good morning " + eG + "!");
  1353.                                 if (LogStatus == 1)
  1354.                                 {
  1355.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1356.                                     richTextBox1.AppendText("Uny: Good morning " + eG + "!" + Environment.NewLine);
  1357.                                 }
  1358.                                 await Task.Delay(5000);
  1359.                                 r = null;
  1360.                                 eoc();
  1361.                                 return;
  1362.                             }
  1363.  
  1364.                             if (m == "good afternoon")
  1365.                             {
  1366.                                 say("good afternoon " + eG + "!");
  1367.                                 Console.WriteLine("Uny: Good afternoon " + eG + "!");
  1368.                                 if (LogStatus == 1)
  1369.                                 {
  1370.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1371.                                     richTextBox1.AppendText("Uny: Good afternoon " + eG + "!" + Environment.NewLine);
  1372.                                 }
  1373.                                 await Task.Delay(5000);
  1374.                                 r = null;
  1375.                                 eoc();
  1376.                                 return;
  1377.                             }
  1378.  
  1379.                             if (m == "good evening")
  1380.                             {
  1381.                                 say("good evening " + eG);
  1382.                                 Console.WriteLine("Uny: Good evening " + eG + "!");
  1383.                                 if (LogStatus == 1)
  1384.                                 {
  1385.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1386.                                     richTextBox1.AppendText("Uny: Good evening " + eG + "!" + Environment.NewLine);
  1387.                                 }
  1388.                                 await Task.Delay(5000);
  1389.                                 r = null;
  1390.                                 eoc();
  1391.                                 return;
  1392.                             }
  1393.                             if (m == "who is lua")
  1394.                             {
  1395.                                 say("the main developer of you ni");
  1396.                                 startCRed();
  1397.                                 Console.WriteLine("Uny: The main developer of Uny!");
  1398.                                 endC();
  1399.                                 if (LogStatus == 1)
  1400.                                 {
  1401.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1402.                                     richTextBox1.AppendText("Uny: The main developer of Uny!" + Environment.NewLine);
  1403.                                 }
  1404.                                 await Task.Delay(5000);
  1405.                                 r = null;
  1406.                                 eoc();
  1407.                                 return;
  1408.                             }
  1409.  
  1410.                             if (m == "shut up")
  1411.                             {
  1412.                                 say("okay, I will shut up!");
  1413.                                 if (LogStatus == 1)
  1414.                                 {
  1415.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1416.                                     richTextBox1.AppendText("Engine: Stopping Uny for 10 seconds!" + Environment.NewLine);
  1417.                                     richTextBox1.AppendText("Uny: Okay, I will shut up!" + Environment.NewLine);
  1418.                                 }
  1419.                                 Console.WriteLine("Uny: Okay, I will shut up!");
  1420.                                 await Task.Delay(5000);
  1421.  
  1422.                                 System.Threading.Thread.Sleep(10000);
  1423.                                 say("I will talk now again!");
  1424.                                 Console.WriteLine("Uny: I will talk now again!");
  1425.                                 if (LogStatus == 1)
  1426.                                 {
  1427.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1428.                                     richTextBox1.AppendText("Uny: I will talk now again!" + Environment.NewLine);
  1429.                                 }
  1430.                                 await Task.Delay(5000);
  1431.                                 r = null;
  1432.                                 eoc();
  1433.                                 return;
  1434.                             }
  1435.  
  1436.                             if (m == "open my playlist")
  1437.                             {
  1438.                                 dS();
  1439.                                 Console.WriteLine("Uny: *done sound*");
  1440.  
  1441.                                 string link = "https://www.youtube.com/watch?v=HNK1YjheVUA&list=PLTzHfqYskDi9tpH5tte4qeQjOADn1b77J&index=2&t=0s";
  1442.                                 Process.Start("chrome", link);
  1443.                                 if (LogStatus == 1)
  1444.                                 {
  1445.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1446.                                     richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
  1447.                                 }
  1448.                                 await Task.Delay(5000);
  1449.  
  1450.                                 r = null;
  1451.                                 eoc();
  1452.                                 return;
  1453.                             }
  1454.  
  1455.                             if (m == "i am good")
  1456.                             {
  1457.                                 say("That's nice to hear");
  1458.                                 Console.WriteLine("Uny: That's nice to hear!");
  1459.                                 if (LogStatus == 1)
  1460.                                 {
  1461.                                     richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1462.                                     richTextBox1.AppendText("Uny: That's nice to hear!" + Environment.NewLine);
  1463.                                 }
  1464.                                 await Task.Delay(5000);
  1465.                                 r = null;
  1466.                                 eoc();
  1467.                                 return;
  1468.                             }
  1469.  
  1470.                             r = null;
  1471.                             eoc();
  1472.                             return;
  1473.                         }
  1474.                     }
  1475.                 }
  1476.                 else if (r != "hello uny")
  1477.                 {
  1478.                     r = null;
  1479.                     resultString = null;
  1480.                 }
  1481.             }
  1482.         }
  1483.  
  1484.         private void dS()
  1485.         {
  1486.             string Soundpath = localPath + @"listenSound.wav";
  1487.             System.Media.SoundPlayer player = new System.Media.SoundPlayer(Soundpath);
  1488.             player.Play();
  1489.         }
  1490.         private void listenSound()
  1491.         {
  1492.             string Soundpath = localPath + @"listenNowSound.wav";
  1493.             System.Media.SoundPlayer player = new System.Media.SoundPlayer(Soundpath);
  1494.             player.Play();
  1495.         }
  1496.  
  1497.         private void label3_Click(object sender, EventArgs e)
  1498.         {
  1499.  
  1500.         }
  1501.  
  1502.         private async void pictureBox1_Click(object sender, EventArgs e)
  1503.         {
  1504.             say("shutting down");
  1505.             pictureBox1.Image = Uny.Properties.Resources.Exit_pressed;
  1506.             await Task.Delay(1000);
  1507.             pictureBox1.Image = Uny.Properties.Resources.Exit;
  1508.             Application.Exit();
  1509.         }
  1510.  
  1511.         private async void pictureBox3_Click(object sender, EventArgs e)
  1512.         {
  1513.             say("minimizing the UI");
  1514.             pictureBox3.Image = Uny.Properties.Resources.minimize_pressed;
  1515.             await Task.Delay(500);
  1516.             pictureBox3.Image = Uny.Properties.Resources.minimize;
  1517.             this.Hide();
  1518.             FormActive = 0;
  1519.             Console.ForegroundColor = ConsoleColor.Magenta;
  1520.             cw("Hiding Uny UI");
  1521.             Console.ForegroundColor = ConsoleColor.White;
  1522.         }
  1523.  
  1524.         private async void pictureBox2_Click(object sender, EventArgs e)
  1525.         {
  1526.             pictureBox2.Image = Uny.Properties.Resources.fullscreen_pressed;
  1527.             if (LogStatus == 1)
  1528.             {
  1529.                 richTextBox1.AppendText("User: " + m + Environment.NewLine);
  1530.                 richTextBox1.AppendText("Engine: This function is still work in progress!" + Environment.NewLine);
  1531.             }
  1532.             inWork.Visible = true;
  1533.             await Task.Delay(250);
  1534.             inWork.Visible = false;
  1535.             pictureBox2.Image = Uny.Properties.Resources.Fullscreen;
  1536.         }
  1537.  
  1538.         private void Form1_Load(object sender, EventArgs e)
  1539.         {
  1540.  
  1541.         }
  1542.  
  1543.         public int LogStatus = 0;
  1544.  
  1545.         private async void pictureBox5_Click(object sender, EventArgs e)
  1546.         {
  1547.             if (pictureBox5.Image == staticDeactivated)
  1548.             {
  1549.                 pictureBox5.Image = movingToActivated;
  1550.                 await Task.Delay(600);
  1551.                 pictureBox5.Image = staticActivated;
  1552.                 LogStatus = 1;
  1553.                 panel4.Visible = true;
  1554.                 await Task.Delay(3000);
  1555.                 return;
  1556.             }
  1557.             if (pictureBox5.Image == staticActivated)
  1558.             {
  1559.                 pictureBox5.Image = movingToDeactivated;
  1560.                 await Task.Delay(600);
  1561.                 pictureBox5.Image = staticDeactivated;
  1562.                 LogStatus = 0;
  1563.                 panel4.Visible = false;
  1564.                 return;
  1565.             }
  1566.         }
  1567.  
  1568.         private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  1569.         {
  1570.             richTextBox1.Visible = false;
  1571.             staticActivated.Dispose();
  1572.             staticDeactivated.Dispose();
  1573.             movingToActivated.Dispose();
  1574.             movingToDeactivated.Dispose();
  1575.         }
  1576.         public string typeCC1;
  1577.         public string actionCC1;
  1578.         public string callCC1;
  1579.         public int existCC1 = 0;
  1580.  
  1581.         private void button2_Click(object sender, EventArgs e)
  1582.         {
  1583.             if(existCC1 == 0)
  1584.             {
  1585.                 int preExist = 0;
  1586.  
  1587.                 string[] previously = File.ReadAllLines(localPath + @"Config.txt");
  1588.  
  1589.                 foreach (string x in previously)
  1590.                 {
  1591.                     if (x.Contains("CC1@exist") == true)
  1592.                     {
  1593.                         preExist = 1;
  1594.                     }
  1595.                 }
  1596.                 AddCC addCC = new AddCC();
  1597.                 addCC.ShowDialog();
  1598.                 addCC.Dispose();
  1599.  
  1600.                 string[] config = File.ReadAllLines(localPath + @"Config.txt");
  1601.  
  1602.                 foreach (string r in config)
  1603.                 {
  1604.                     if (r.Contains("CC1@exist") == true)
  1605.                     {
  1606.                         existCC1 = 1;
  1607.                         Console.WriteLine("Custom Command 1 exists!");
  1608.                         if (preExist == 0)
  1609.                         {
  1610.                             preExist = 1;
  1611.                             System.Diagnostics.Process.Start(Application.ExecutablePath);
  1612.                             Application.Exit();
  1613.                         }
  1614.                     }
  1615.                     if (r.Contains("CC1type@") == true)
  1616.                     {
  1617.                         typeCC1 = r.Split(Convert.ToChar("@")).Last();
  1618.                         Console.WriteLine("Type of Custom Command 1: " + typeCC1);
  1619.                     }
  1620.                     if (r.Contains("CC1action@") == true)
  1621.                     {
  1622.                         actionCC1 = r.Split(Convert.ToChar("@")).Last();
  1623.                         Console.WriteLine("Action of Custom Command 1: " + actionCC1);
  1624.                     }
  1625.                     if (r.Contains("CC1call@") == true)
  1626.                     {
  1627.                         callCC1 = r.Split(Convert.ToChar("@")).Last();
  1628.                         Console.WriteLine("Call of Custom Command 1: " + callCC1);
  1629.                     }
  1630.                 }
  1631.             } else
  1632.             {
  1633.                 MessageBox.Show("Custom Command 1 already set!");
  1634.             }
  1635.         }
  1636.  
  1637.         private async void panel5_MouseHover(object sender, EventArgs e)
  1638.         {
  1639.             usernameLabel.Visible = true;
  1640.             textBox1.Visible = true;
  1641.             if(panel1.Width == 0)
  1642.             {
  1643.                 panel1.Width = 1;
  1644.                 panel2.Width = 1;
  1645.                 await Task.Delay(50);
  1646.                 panel1.Width = 50;
  1647.                 panel2.Width = 50;
  1648.                 await Task.Delay(50);
  1649.                 panel1.Width = 100;
  1650.                 panel2.Width = 100;
  1651.                 await Task.Delay(50);
  1652.                 panel1.Width = 150;
  1653.                 panel2.Width = 150;
  1654.                 await Task.Delay(50);
  1655.                 panel1.Width = 200;
  1656.                 panel2.Width = 200;
  1657.                 await Task.Delay(50);
  1658.                 panel1.Width = 250;
  1659.                 panel2.Width = 250;
  1660.                 await Task.Delay(50);
  1661.                 panel1.Width = 300;
  1662.                 panel2.Width = 300;
  1663.             }
  1664.         }
  1665.  
  1666.         private void panel5_MouseLeave(object sender, EventArgs e)
  1667.         {
  1668.  
  1669.         }
  1670.  
  1671.         private async void panel6_MouseLeave(object sender, EventArgs e)
  1672.         {
  1673.             if(panel1.Width == 300)
  1674.             {
  1675.                 panel1.Width = 300;
  1676.                 panel2.Width = 300;
  1677.                 await Task.Delay(50);
  1678.                 panel1.Width = 250;
  1679.                 panel2.Width = 250;
  1680.                 await Task.Delay(50);
  1681.                 panel1.Width = 200;
  1682.                 panel2.Width = 200;
  1683.                 await Task.Delay(50);
  1684.                 panel1.Width = 150;
  1685.                 panel2.Width = 150;
  1686.                 await Task.Delay(50);
  1687.                 panel1.Width = 100;
  1688.                 panel2.Width = 100;
  1689.                 await Task.Delay(50);
  1690.                 panel1.Width = 50;
  1691.                 panel2.Width = 50;
  1692.                 await Task.Delay(50);
  1693.                 panel1.Width = 0;
  1694.                 panel2.Width = 0;
  1695.                 panel5.Visible = true;
  1696.                 usernameLabel.Visible = false;
  1697.                 textBox1.Visible = false;
  1698.             }
  1699.         }
  1700.  
  1701.         public void startCRed()
  1702.         {
  1703.             Console.ForegroundColor = ConsoleColor.Red;
  1704.         }
  1705.  
  1706.         public void endC()
  1707.         {
  1708.             Console.ForegroundColor = ConsoleColor.White;
  1709.         }
  1710.  
  1711.         private void button3_Click(object sender, EventArgs e) //WHITESPACE ERROR, PHRASE MAYBE LOOK INTO ADDCC AND CHANG ENVIRONMENT.NEWLINE OR APPENDALLTEXT
  1712.         {
  1713.             if (MessageBox.Show("Are you sure?", "Confirm deleting CC1", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
  1714.             {
  1715.                     startCRed();
  1716.                     cw("Deleting in Progress...");
  1717.                     endC();
  1718.  
  1719.  
  1720.                     string[] lines = File.ReadAllLines(localPath + "Config.txt");
  1721.  
  1722.                     List<string> ContentConfig = new List<string>();
  1723.                     ContentConfig.Add("UN@" + eU);
  1724.                     foreach (string line in lines)
  1725.                     {
  1726.                         if(!line.Contains("CC1") && line != "UN@" + eU)
  1727.                         {
  1728.                             ContentConfig.Add(line);
  1729.                         }
  1730.                     }
  1731.  
  1732.                     string[] languageLines = File.ReadAllLines(localPath + "languagePack.txt");
  1733.  
  1734.                     List<string> ContentPack = new List<string>();
  1735.                     ContentPack.Add("hey uny");
  1736.                     foreach (string languageLine in languageLines)
  1737.                     {
  1738.                         if (!languageLine.Contains(callCC1) && languageLine != "hey uny" && string.IsNullOrEmpty(languageLine) != true && string.IsNullOrWhiteSpace(languageLine) != true)
  1739.                         {
  1740.                         ContentPack.Add(languageLine);
  1741.                         }
  1742.                     }
  1743.  
  1744.                 System.IO.File.WriteAllLines(localPath + @"languagePack.txt", ContentPack);
  1745.                 System.IO.File.WriteAllLines(localPath + @"Config.txt", ContentConfig);
  1746.  
  1747.                 if (System.IO.File.Exists(@"C:\Windows\System32\Config.txt"))
  1748.                 {
  1749.                     System.IO.File.Delete(@"C:\Windows\System32\Config.txt");
  1750.                 }
  1751.                 if (System.IO.File.Exists(@"C:\Windows\System32\languagePack.txt"))
  1752.                 {
  1753.                     System.IO.File.Delete(@"C:\Windows\System32\languagePack.txt");
  1754.                 }
  1755.  
  1756.                 System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"Config.txt", @"C:\Windows\System32\Config.txt");
  1757.                 System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"languagePack.txt", @"C:\Windows\System32\languagePack.txt");
  1758.  
  1759.                 var lastLanguageLines = System.IO.File.ReadAllLines(localPath + @"languagePack.txt");
  1760.                 System.IO.File.WriteAllLines(localPath + @"languagePack.txt", lastLanguageLines.Take(lastLanguageLines.Length - 1).ToArray());
  1761.                 var lastConLines = System.IO.File.ReadAllLines(localPath + @"Config.txt");
  1762.                 System.IO.File.WriteAllLines(localPath + @"Config.txt", lastConLines.Take(lastConLines.Length - 1).ToArray());
  1763.  
  1764.                 if (System.IO.File.Exists(@"C:\Windows\System32\Config.txt"))
  1765.                 {
  1766.                     System.IO.File.Delete(@"C:\Windows\System32\Config.txt");
  1767.                 }
  1768.                 if (System.IO.File.Exists(@"C:\Windows\System32\languagePack.txt"))
  1769.                 {
  1770.                     System.IO.File.Delete(@"C:\Windows\System32\languagePack.txt");
  1771.                 }
  1772.  
  1773.                 System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"Config.txt", @"C:\Windows\System32\Config.txt");
  1774.                 System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"languagePack.txt", @"C:\Windows\System32\languagePack.txt");
  1775.  
  1776.                 System.Diagnostics.Process.Start(Application.ExecutablePath);
  1777.                 Application.Exit();
  1778.                
  1779.             }
  1780.             else
  1781.             {
  1782.                 startCRed();
  1783.                 cw("Not deleting!");
  1784.                 endC();
  1785.             }
  1786.         }
  1787.  
  1788.         private async void button4_Click(object sender, EventArgs e)
  1789.         {
  1790.             if(atStat == 1)
  1791.             {
  1792.                 RegistryKey rk = Registry.CurrentUser.OpenSubKey
  1793.                             ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  1794.                 rk.DeleteValue("Uny", false);
  1795.                 atStat = 0;
  1796.                 button4.Text = "Turn off";
  1797.                 button4.Visible = false;
  1798.                 await Task.Delay(3000);
  1799.                 button4.Visible = true;
  1800.             }
  1801.             if(atStat == 0)
  1802.             {
  1803.                 RegistryKey rk = Registry.CurrentUser.OpenSubKey
  1804.                             ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  1805.                 rk.SetValue("Uny", Application.ExecutablePath);
  1806.                 atStat = 1;
  1807.                 button4.Text = "Turn on";
  1808.                 button4.Visible = false;
  1809.                 await Task.Delay(3000);
  1810.                 button4.Visible = true;
  1811.             }
  1812.         }
  1813.  
  1814.         [DllImport("user32.dll")]
  1815.         public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  1816.         private void button5_Click(object sender, EventArgs e)
  1817.         {
  1818.             const uint WM_KEYDOWN = 0x100;
  1819.             const uint WM_KEYUP = 0x0101;
  1820.  
  1821.             IntPtr hWnd;
  1822.             string processName = "Discord";
  1823.             Process[] processList = Process.GetProcesses();
  1824.  
  1825.             foreach(Process p in processList)
  1826.             {
  1827.                 if(p.ProcessName.Contains(processName) == true)
  1828.                 {
  1829.                     IntPtr edit = p.MainWindowHandle;
  1830.                     PostMessage(edit, WM_KEYDOWN, (IntPtr)(Keys.Control), IntPtr.Zero);
  1831.                     PostMessage(edit, WM_KEYDOWN, (IntPtr)(Keys.Enter), IntPtr.Zero);
  1832.                     PostMessage(edit, WM_KEYUP, (IntPtr)(Keys.Enter), IntPtr.Zero);
  1833.                     PostMessage(edit, WM_KEYUP, (IntPtr)(Keys.Control), IntPtr.Zero);
  1834.                 }
  1835.             }
  1836.         }
  1837.     }
  1838. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement