Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Speech.Synthesis;
- using System.Speech.Recognition;
- using System.Diagnostics;
- using System.IO;
- using System.Threading;
- using System.Runtime.InteropServices;
- using AudioSwitcher.AudioApi.CoreAudio;
- using System.Drawing;
- using System.Collections.Generic;
- using Microsoft.Win32;
- using System.Management.Automation.Runspaces;
- using System.Collections.ObjectModel;
- using System.Management.Automation;
- using System.Text;
- //Alles was du sagst wiederholt Uny in diesen komischen Voice Pack was total real klingt von Marvin
- namespace Uny
- {
- public partial class Main : Form
- {
- public int atStat = 0;
- public SpeechSynthesizer synthesizer = new SpeechSynthesizer();
- public Choices list = new Choices();
- public SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine();
- public GrammarBuilder grammabuild = new GrammarBuilder();
- public SpeechSynthesizer synth = new SpeechSynthesizer();
- public Choices seclist = new Choices();
- public SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
- public GrammarBuilder secgrammabuild = new GrammarBuilder();
- acceptDiscordCall aDC = new acceptDiscordCall();
- public Main()
- {
- ReadConfig();
- try
- {
- var KHK = File.ReadAllLines(System.AppDomain.CurrentDomain.BaseDirectory + @"languagePack.txt").ToArray();
- foreach (var line in KHK)
- {
- string eachLine = Convert.ToString(line);
- list.Add(eachLine);
- }
- } catch (Exception exc)
- {
- Console.WriteLine("Exception catched when loading languagePack! At line: -- {0}", exc);
- }
- grammabuild.Append(list);
- Grammar gr = new Grammar(grammabuild);
- try
- {
- recognitionEngine.RequestRecognizerUpdate();
- recognitionEngine.LoadGrammarAsync(gr);
- recognitionEngine.SpeechRecognized += recognitionEngine_SpeechRecognized;
- recognitionEngine.SetInputToDefaultAudioDevice();
- recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
- }
- catch (Exception exc)
- {
- Console.WriteLine("Exception catched -- {0}", exc);
- return;
- }
- synthesizer.SelectVoiceByHints(VoiceGender.Female);
- synthesizer.SpeakAsync("You ni activated");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("Uny Protocol - Development Version " + curDevVersion);
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine(" ");
- string currentTime = DateTime.Now.ToString("hh:mm tt");
- string textTime = DateTime.Now.ToString("hh:mm tt");
- Console.ForegroundColor = ConsoleColor.Cyan;
- Console.WriteLine("Current Time: " + textTime);
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine(" ");
- if (currentTime.Contains("AM") == true)
- {
- say("good morning user!");
- }
- else if (currentTime.Contains("01:") == true || currentTime.Contains("02:") == true && currentTime.Contains("PM") == true)
- {
- say("good afternoon user!");
- }
- else if (currentTime.Contains("03:") == true || currentTime.Contains("04:") == true && currentTime.Contains("PM") == true)
- {
- say("good afternoon user!");
- }
- else if (currentTime.Contains("05:") == true && currentTime.Contains("PM") == true)
- {
- say("good afternoon user!");
- }
- else if (currentTime.Contains("06:") == true || currentTime.Contains("07:") && currentTime.Contains("PM") == true)
- {
- say("good evening user!");
- }
- else if (currentTime.Contains("08:") == true || currentTime.Contains("09:") && currentTime.Contains("PM") == true)
- {
- say("good evening user!");
- }
- else if (currentTime.Contains("10:") == true || currentTime.Contains("11:") && currentTime.Contains("PM") == true)
- {
- say("good evening user!");
- }
- else if (currentTime.Contains("12:") == true && currentTime.Contains("AM") == true)
- {
- say("good evening user!");
- }
- else if (currentTime.Contains("12:") == true && currentTime.Contains("PM") == true)
- {
- say("good afternoon user!");
- }
- string[] localPathRead = System.IO.File.ReadAllLines(System.AppDomain.CurrentDomain.BaseDirectory + @"Config.txt");
- foreach(string line in localPathRead)
- {
- if(line.Contains("local@") == true)
- {
- localPath = line.Split(Convert.ToChar("@")).Last();
- }
- }
- InitializeComponent();
- panel1.Width = 0;
- staticDeactivated = Uny.Properties.Resources.Uny_Slider_one;
- staticActivated = Uny.Properties.Resources.Uny_Slider_two;
- movingToActivated = Uny.Properties.Resources.activating_gif;
- movingToDeactivated = Uny.Properties.Resources.deactivating_gif;
- pictureBox5.Image = staticDeactivated;
- label6.Visible = false;
- label7.Visible = false;
- label8.Visible = false;
- panel4.Visible = false;
- inWork.Visible = false;
- textBox1.Visible = false;
- usernameLabel.Visible = false;
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Uny activated");
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine(" ");
- Console.WriteLine("------------------------------------------------");
- Console.WriteLine(" ");
- string[] cc1 = File.ReadAllLines(localPath + @"Config.txt");
- foreach (string v in cc1)
- {
- if (v.Contains("CC1@exist") == true)
- {
- existCC1 = 1;
- Console.WriteLine("Custom Command 1 exists!");
- }
- if (v.Contains("CC1type@") == true)
- {
- typeCC1 = v.Split(Convert.ToChar("@")).Last();
- Console.WriteLine("Type of Custom Command 1: " + typeCC1);
- }
- if (v.Contains("CC1action@") == true)
- {
- actionCC1 = v.Split(Convert.ToChar("@")).Last();
- Console.WriteLine("Action of Custom Command 1: " + actionCC1);
- }
- if (v.Contains("CC1call@") == true)
- {
- callCC1 = v.Split(Convert.ToChar("@")).Last();
- Console.WriteLine("Call of Custom Command 1: " + callCC1);
- }
- if(v.Contains("at@") == true)
- {
- if(v.Contains("1") == true)
- {
- button4.Text = "Turn off";
- atStat = 1;
- } else if(v.Contains("0") == true)
- {
- button4.Text = "Turn on";
- }
- }
- }
- if(existCC1 == 1)
- {
- button2.Text = "Custom Command 1 is active!";
- label6.Text = "type: " + typeCC1;
- label6.Visible = true;
- label7.Text = "call: " + callCC1;
- label7.Visible = true;
- label8.Text = "action: " + actionCC1;
- label8.Visible = true;
- }
- while (resultString == null)
- {
- try
- {
- recognitionEngine.RequestRecognizerUpdate();
- recognitionEngine.LoadGrammarAsync(gr);
- recognitionEngine.SpeechRecognized += recognitionEngine_SpeechRecognized;
- recognitionEngine.SetInputToDefaultAudioDevice();
- recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
- }
- catch (Exception exc)
- {
- Console.WriteLine("Exception catched -- {0}", exc);
- Console.WriteLine("Make sure the microphone is being found!");
- return;
- }
- }
- label5.Text = "synchronizing data...";
- label5.Visible = false;
- }
- public string localPath = null;
- private void label5_TextChanged(object sender, EventArgs e)
- {
- if (GEexist == 0 && UNexist == 0)
- {
- Registration registration = new Registration();
- registration.ShowDialog();
- }
- }
- //CURRENT DEV VERSION
- public string curDevVersion = "2.5";
- //CURRENT DEV VERSION
- public int GEexist = 0;
- public int UNexist = 0;
- public string eU;
- public string eG;
- public void ReadConfig()
- {
- string[] config = File.ReadAllLines(localPath + @"Config.txt");
- string UNisEmpty = "Username is empty!";
- string GEisEmpty = "Gender is empty!";
- foreach (string r in config)
- {
- if(r.Contains("UN@") == true)
- {
- try
- {
- string Username = r.Split(Convert.ToChar("@")).Last();
- if(string.IsNullOrEmpty(Username) != true)
- {
- Console.WriteLine("First Line detected! -- {0}", Username);
- eU = Username;
- UNexist = 1;
- } else
- {
- Console.WriteLine("First Line detected! -- {0}", UNisEmpty);
- }
- } catch (Exception exc)
- {
- Console.WriteLine("Exception catched at Line 179! -- {0}", exc);
- }
- }
- if(r.Contains("GE@") == true)
- {
- try
- {
- string Gender = r.Split(Convert.ToChar("@")).Last();
- if(string.IsNullOrEmpty(Gender) != true)
- {
- Console.WriteLine("Second Line detected! -- {0}", Gender);
- if(Gender == "Female")
- {
- eG = "Madame";
- } else if(Gender == "Male")
- {
- eG = "Sir";
- }
- GEexist = 1;
- } else
- {
- Console.WriteLine("Second Line detected! -- {0}", GEisEmpty);
- }
- } catch (Exception exc)
- {
- Console.WriteLine("Exception catched at Line 198! -- {0}", exc);
- }
- }
- }
- }
- protected override void WndProc(ref Message m)
- {
- base.WndProc(ref m);
- if (m.Msg == WM_NCHITTEST)
- m.Result = (IntPtr)(HT_CAPTION);
- }
- private const int WM_NCHITTEST = 0x84;
- private const int HT_CLIENT = 0x1;
- private const int HT_CAPTION = 0x2;
- public string resultString = Convert.ToString(1);
- public const int KEYEVENTF_EXTENDKEY = 1;
- public const int KEYEVENTF_KEYUP = 0;
- public const int VK_MEDIA_NEXT_TRACK = 0xB0;
- public const int VK_MEDIA_PLAY_PAUSE = 0xB3;
- public const int VK_MEDIA_PREV_TRACK = 0xB1;
- [DllImport("user32.dll")]
- public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo);
- [DllImport("User32.dll")]
- static extern IntPtr GetForegroundWindow();
- [DllImport("User32.dll", SetLastError = true)]
- static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint IpdwProcessId);
- [DllImport("USER32.DLL")]
- public static extern Int32 SetForegroundWindow(int hWnd);
- [DllImport("User32.DLL", CharSet = CharSet.Unicode)]
- public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
- public int discordVerified;
- public string discordPath;
- public void getDiscordProcess()
- {
- try
- {
- Process[] processes = Process.GetProcessesByName("Discord");
- Process discord = processes[0];
- }
- catch
- {
- Console.WriteLine("Discord was not found!");
- discordVerified = 0;
- }
- }
- private Image staticDeactivated;
- private Image staticActivated;
- private Image movingToActivated;
- private Image movingToDeactivated;
- public void say(String h)
- {
- synthesizer.SpeakAsync(h);
- }
- public void listenNow()
- {
- var KHK = File.ReadAllLines(@"languagePack.txt").ToArray();
- foreach (var line in KHK)
- {
- string eachLine = Convert.ToString(line);
- seclist.Add(eachLine);
- }
- secgrammabuild.Append(seclist);
- Grammar gr = new Grammar(secgrammabuild);
- try
- {
- rec.RequestRecognizerUpdate();
- rec.LoadGrammarAsync(gr);
- rec.SpeechRecognized += recEngine_SpeechRecognized;
- rec.SetInputToDefaultAudioDevice();
- rec.RecognizeAsync(RecognizeMode.Multiple);
- }
- catch
- {
- return;
- }
- }
- private string runScript(string script)
- {
- Runspace runspace = RunspaceFactory.CreateRunspace();
- runspace.Open();
- Pipeline pipeline = runspace.CreatePipeline();
- pipeline.Commands.AddScript(script);
- pipeline.Commands.Add("Out-String");
- Collection<PSObject> results = pipeline.Invoke();
- runspace.Close();
- StringBuilder sb = new StringBuilder();
- foreach (PSObject ps in results)
- {
- sb.AppendLine(ps.ToString());
- }
- return sb.ToString();
- }
- public string mainListenString;
- public void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
- {
- String r = e.Result.Text;
- mainListenString = r;
- }
- public void eoc()
- {
- resultString = null;
- mainListenString = null;
- }
- public ManualResetEvent waitForStringEvent = new ManualResetEvent(false);
- public string m;
- public CoreAudioDevice defaultPlaybackDevice = new CoreAudioController().DefaultPlaybackDevice;
- public void getCurrentVolume()
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Current Volume:" + defaultPlaybackDevice.Volume);
- Console.ForegroundColor = ConsoleColor.White;
- }
- public void cw(String t)
- {
- Console.WriteLine(t);
- }
- private int FormActive = 1;
- public void cbg(String v)
- {
- if(eG == "Sir")
- {
- say(v + "sir");
- } else if (eG == "Madame")
- {
- say(v + "madame");
- }
- }
- System.Windows.Forms.Timer v = null;
- private void resetAwaitListen()
- {
- v = new System.Windows.Forms.Timer();
- v.Interval = 5000;
- v.Tick += new EventHandler(action);
- v.Enabled = true;
- }
- void action(object sender, EventArgs e)
- {
- awaitListen = false;
- }
- public bool awaitListen = false;
- public async void recognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
- {
- String r = e.Result.Text;
- resultString = null;
- resultString = r;
- Console.WriteLine("User: " + r);
- while (resultString != null)
- {
- if (r == "hello uny" || r == "hey uny" && GEexist == 1 && UNexist == 1)
- {
- string greetingChoice = " ";
- Random random = new Random();
- int randomNumber = random.Next(0, 100);
- if (randomNumber < 25)
- {
- greetingChoice = " ";
- Console.Write("Uny: ");
- Console.ForegroundColor = ConsoleColor.DarkCyan;
- Console.WriteLine("listen sound");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else if (randomNumber > 25 && randomNumber < 50)
- {
- greetingChoice = "Yes?";
- Console.Write("Uny: ");
- Console.ForegroundColor = ConsoleColor.DarkCyan;
- Console.WriteLine("Yes?");
- Console.ForegroundColor = ConsoleColor.White;
- listenSound();
- }
- else if (randomNumber > 50 && randomNumber < 75)
- {
- greetingChoice = " ";
- Console.Write("Uny: ");
- Console.ForegroundColor = ConsoleColor.DarkCyan;
- Console.WriteLine("listen sound");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else if (randomNumber > 75)
- {
- greetingChoice = "How can I help you " + eG;
- Console.Write("Uny: ");
- Console.ForegroundColor = ConsoleColor.DarkCyan;
- Console.WriteLine("How can I help you " + eG + "?");
- Console.ForegroundColor = ConsoleColor.White;
- }
- if (greetingChoice == " ")
- {
- listenSound();
- } else
- {
- say(greetingChoice);
- }
- listenNow();
- if(randomNumber > 75)
- {
- await Task.Delay(6000);
- } else
- {
- await Task.Delay(4000);
- }
- m = mainListenString;
- awaitListen = true;
- resetAwaitListen();
- while (awaitListen == true)
- {
- while (!string.IsNullOrEmpty(m))
- {
- if (existCC1 == 1)
- {
- if (m == callCC1)
- {
- if (typeCC1 == "respond")
- {
- say(actionCC1);
- Console.WriteLine("Uny: " + actionCC1);
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: " + actionCC1 + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- else if (typeCC1 == "open tab")
- {
- Process.Start("chrome.exe", actionCC1);
- dS();
- Console.WriteLine("Engine: Opening " + actionCC1);
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Opening " + actionCC1 + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- }
- }
- if(m == "open calculator" || m == "open the calculator")
- {
- Process.Start("calc.exe");
- dS();
- Console.WriteLine("Engine: Starting calculator app!");
- Console.WriteLine("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Starting calculator app!");
- }
- await Task.Delay(3000);
- r = null;
- eoc();
- return;
- }
- if (m == "open the explorer")
- {
- dS();
- Process.Start("explorer.exe");
- Console.WriteLine("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "open youtube")
- {
- dS();
- Process.Start("chrome.exe", "http://youtube.com");
- cw("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "nevermind" || m == "nothing" || m == "forget about it" || m == "forget it")
- {
- dS();
- Console.WriteLine("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(3000);
- r = null;
- eoc();
- return;
- }
- if (m == "open panel" || m == "open options")
- {
- if (panel1.Width == 0)
- {
- dS();
- Console.ForegroundColor = ConsoleColor.Magenta;
- cw("Opening panel!");
- Console.ForegroundColor = ConsoleColor.White;
- cw("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Opening panel!" + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- usernameLabel.Visible = true;
- textBox1.Visible = true;
- panel1.Width = 1;
- panel2.Width = 1;
- await Task.Delay(50);
- panel1.Width = 50;
- panel2.Width = 50;
- await Task.Delay(50);
- panel1.Width = 100;
- panel2.Width = 100;
- await Task.Delay(50);
- panel1.Width = 150;
- panel2.Width = 150;
- await Task.Delay(50);
- panel1.Width = 200;
- panel2.Width = 200;
- await Task.Delay(50);
- panel1.Width = 250;
- panel2.Width = 250;
- await Task.Delay(50);
- panel1.Width = 300;
- panel2.Width = 300;
- }
- else
- {
- say("Option panel is already open!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Option panel is already open!" + Environment.NewLine);
- }
- }
- r = null;
- eoc();
- return;
- }
- if (m == "close panel" || m == "close options")
- {
- if (panel1.Width == 300)
- {
- dS();
- Console.ForegroundColor = ConsoleColor.Magenta;
- cw("Closing panel!");
- Console.ForegroundColor = ConsoleColor.White;
- cw("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Closing Panel!" + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- panel1.Width = 300;
- panel2.Width = 300;
- await Task.Delay(50);
- panel1.Width = 250;
- panel2.Width = 250;
- await Task.Delay(50);
- panel1.Width = 200;
- panel2.Width = 200;
- await Task.Delay(50);
- panel1.Width = 150;
- panel2.Width = 150;
- await Task.Delay(50);
- panel1.Width = 100;
- panel2.Width = 100;
- await Task.Delay(50);
- panel1.Width = 50;
- panel2.Width = 50;
- await Task.Delay(50);
- panel1.Width = 0;
- panel2.Width = 0;
- usernameLabel.Visible = false;
- textBox1.Visible = false;
- }
- else
- {
- say("Option panel is already closed!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Option Panel is already closed!" + Environment.NewLine);
- }
- }
- r = null;
- eoc();
- return;
- }
- if (m == "open twitch")
- {
- dS();
- Process.Start("chrome.exe", "https://www.twitch.tv/");
- cw("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if(m == "network scan")
- {
- dS();
- if(LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- say("Scanning the local network, this might take a while");
- richTextBox1.AppendText("Uny: " + runScript("1..254 | ForEach-Object {Test-Connection -ComputerName \"192.168.0.$_\" -Count 1 -ErrorAction SilentlyContinue}"));
- say("Scan is done, you can now see the result in the log section");
- } else
- {
- say("Log panel must be activated to use network functions");
- ; }
- await Task.Delay(3000);
- r = null;
- eoc();
- return;
- }
- if (m == "end your process")
- {
- say("Thank you for using me " + eG);
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Thank you for using me, " + eG + "!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- Application.Exit();
- }
- if (m == "goodbye")
- {
- say("Goodbye user, it was nice serving you " + eU);
- Console.WriteLine("Uny: Goodbye " + eG + ", it was nice serving you " + eU + "!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Goodbye " + eG + ", it was nice serving you " + eU + "!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- 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")
- {
- dS();
- keybd_event(VK_MEDIA_PLAY_PAUSE, 0, KEYEVENTF_EXTENDKEY, IntPtr.Zero);
- Console.WriteLine("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(3000);
- r = null;
- eoc();
- return;
- }
- if (m == "next" || m == "next track" || m == "skip" || m == "skip track")
- {
- dS();
- keybd_event(VK_MEDIA_NEXT_TRACK, 0, KEYEVENTF_EXTENDKEY, IntPtr.Zero);
- Console.WriteLine("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(3000);
- r = null;
- eoc();
- return;
- }
- if (m == "show ui" || m == "show the ui" || m == "open the ui" || m == "open ui")
- {
- if (FormActive == 0)
- {
- dS();
- this.Show();
- Console.ForegroundColor = ConsoleColor.Magenta;
- cw("Activating Uny UI");
- Console.ForegroundColor = ConsoleColor.White;
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Activating Uny UI" + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(3000);
- cw("Uny: *done sound*");
- }
- else
- {
- say("The interface is already open!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: The interface is already open!" + Environment.NewLine);
- }
- }
- r = null;
- eoc();
- return;
- }
- if (m == "hide ui" || m == "hide the ui" || m == "hide the interface" || m == "hide interface" || m == "minimize the interface" || m == "minimize interface")
- {
- if (FormActive == 1)
- {
- dS();
- this.Hide();
- Console.ForegroundColor = ConsoleColor.Magenta;
- cw("Hiding Uny UI");
- Console.ForegroundColor = ConsoleColor.White;
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Hiding Uny UI!" + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- FormActive = 0;
- await Task.Delay(3000);
- cw("Uny: *done sound*");
- }
- else
- {
- say("The interface is already hidden!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: The interface is already hidden!" + Environment.NewLine);
- }
- }
- r = null;
- eoc();
- return;
- }
- if (m == "last track" || m == "last")
- {
- dS();
- keybd_event(VK_MEDIA_PREV_TRACK, 0, KEYEVENTF_EXTENDKEY, IntPtr.Zero);
- Console.WriteLine("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(4000);
- r = null;
- eoc();
- return;
- }
- if (m == "lower system volume by fifty percent" || m == "lower volume by fifty percent")
- {
- say("lowering system volume by 50 percent");
- dS();
- getCurrentVolume();
- cw("Uny: Lowering system volume by 50%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Lowering system volume by 50%" + Environment.NewLine);
- }
- double curVol = defaultPlaybackDevice.Volume;
- double newVol = curVol - 50;
- defaultPlaybackDevice.Volume = newVol;
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "higher system volume by fifty percent" || m == "raise volume by fifty percent" || m == "higher volume by fifty percent")
- {
- say("highering system volume by 50 percent");
- dS();
- getCurrentVolume();
- cw("Uny: Lowering system volume by 50%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Lowering system volume by 50%!" + Environment.NewLine);
- }
- double curVol = defaultPlaybackDevice.Volume;
- double newVol = curVol + 50;
- defaultPlaybackDevice.Volume = newVol;
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "lower system volume by twentyfive percent" || m == "lower volume by twentyfive percent")
- {
- say("lowering system volume by 25 percent");
- dS();
- getCurrentVolume();
- cw("Uny: Lowering system volume by 25%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Lowering system volume by 25%!" + Environment.NewLine);
- }
- double curVol = defaultPlaybackDevice.Volume;
- double newVol = curVol - 25;
- defaultPlaybackDevice.Volume = newVol;
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "higher system volume by twentyfive percent" || m == "raise volume by twentyfive percent" || m == "higher volume by twentyfive percent")
- {
- say("highering system volume by 25 percent");
- dS();
- getCurrentVolume();
- cw("Uny: Highering system volume by 25%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Highering system volume by 25%!" + Environment.NewLine);
- }
- double curVol = defaultPlaybackDevice.Volume;
- double newVol = curVol + 25;
- defaultPlaybackDevice.Volume = newVol;
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "lower system volume by five percent" || m == "lower volume by five percent")
- {
- say("lowering system volume by 5 percent");
- dS();
- getCurrentVolume();
- cw("Uny: Lowering system volume by 5%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Lowering system volume by 5%!" + Environment.NewLine);
- }
- double curVol = defaultPlaybackDevice.Volume;
- double newVol = curVol - 5;
- defaultPlaybackDevice.Volume = newVol;
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "higher system volume by five percent" || m == "raise volume by five percent" || m == "higher volume by five percent")
- {
- say("highering system volume by 5 percent");
- dS();
- getCurrentVolume();
- cw("Uny: Highering system volume by 5%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Highering system volume by 5%!" + Environment.NewLine);
- }
- double curVol = defaultPlaybackDevice.Volume;
- double newVol = curVol + 5;
- defaultPlaybackDevice.Volume = newVol;
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "set system volume to fifty percent" || m == "set volume to fifty percent")
- {
- say("Setting system volume to 50 percent!");
- dS();
- getCurrentVolume();
- cw("Setting system volume to 50%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Setting system volume to 50%!" + Environment.NewLine);
- }
- defaultPlaybackDevice.Volume = 50;
- await Task.Delay(4000);
- r = null;
- eoc();
- return;
- }
- if (m == "set system volume to onehundered percent" || m == "set volume to onehundered percent")
- {
- say("Setting system volume to 100 percent!");
- dS();
- getCurrentVolume();
- cw("Setting system volume to 100%!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Setting system volume to 100%!" + Environment.NewLine);
- }
- defaultPlaybackDevice.Volume = 100;
- await Task.Delay(4000);
- r = null;
- eoc();
- return;
- }
- if (m == "shutdown")
- {
- say("okay, i will shutdown now, goodbye " + eU);
- System.Console.WriteLine("Uny: Okay, I will shutdown now, goodbye " + eU + "!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Okay, I will shutdown now, goodbye " + eU + "!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- Application.Exit();
- }
- if (m == "accept call")
- {
- getDiscordProcess();
- await Task.Delay(2000);
- Console.WriteLine(discordPath);
- if (discordVerified == 1)
- {
- dS();
- Console.Write("Uny: ");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Accepting discord call!");
- Console.ForegroundColor = ConsoleColor.White;
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Accepting discord call!" + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(2000);
- SendKeys.Send("^({Enter})");
- }
- else
- {
- say("discord was not found on your pc!");
- Console.Write("Uny: ");
- Console.ForegroundColor = ConsoleColor.Red;
- cw("Discord was not found on your PC!");
- Console.ForegroundColor = ConsoleColor.White;
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: FATAL ERROR, could not find Discord on your PC!");
- richTextBox1.AppendText("Uny: Discord was not found on your PC!" + Environment.NewLine);
- }
- await Task.Delay(3000);
- }
- r = null;
- eoc();
- return;
- }
- if (m == "open discord" || m == "start discord" || m == "launch discord")
- {
- getDiscordProcess();
- if (discordVerified == 1)
- {
- dS();
- Console.ForegroundColor = ConsoleColor.Red;
- cw("Starting Discord process!");
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write("Uny: ");
- Console.WriteLine("*done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Starting Discord process!" + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- }
- else
- {
- say("I could not find discord on your pc!");
- Console.Write("Uny: ");
- Console.ForegroundColor = ConsoleColor.Red;
- cw("Discord was not found on your PC!");
- Console.ForegroundColor = ConsoleColor.White;
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: FATAL ERROR, could not find Discord on your PC!" + Environment.NewLine);
- richTextBox1.AppendText("Uny: I could not find Discord on your PC!" + Environment.NewLine);
- }
- await Task.Delay(3000);
- }
- r = null;
- eoc();
- return;
- }
- if (m == "can you open chrome" || m == "may you open chrome" || m == "open chrome")
- {
- Process.Start("chrome.exe", "http://google.com");
- dS();
- Console.WriteLine("Uny: *done sound*");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "how are you")
- {
- say("i am good, thanks for asking!");
- Console.WriteLine("Uny: I am good, thanks for asking!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Why are you even asking that? It is a machine, it has no feelings lol" + Environment.NewLine);
- richTextBox1.AppendText("Uny: I am good, thanks for asking!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "thank you")
- {
- say("no problems, i am made for serving!");
- Console.WriteLine("Uny: No problems, I am made for serving!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: No problems, I am made for serving!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "i am back")
- {
- say("welcome back " + eU + "!");
- Console.WriteLine("Uny: Welcome back " + eU + "!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Welcome back " + eU + "!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "you are really helpful")
- {
- say("thank you, I am doing my best to make your life easier!");
- Console.WriteLine("Uny: thank you, I am doing my best to make your life easier!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Thank you, I am doing my best to make your life easier!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "what time is it")
- {
- say("It is " + DateTime.Now.ToString("hh:mm tt"));
- Console.WriteLine("Uny: It is " + DateTime.Now.ToString("hh:mm tt"));
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: It is " + DateTime.Now.ToString("hh:mm tt") + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "who created you")
- {
- say("cresk and lua created me!");
- Console.WriteLine("Uny: Cresk and Lua created me!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Cresk and Lua created me!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "open chrome")
- {
- say("ofcourse!");
- Process.Start("chrome.exe", "http://google.com");
- dS();
- Console.WriteLine("Uny: Ofcourse!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Of course!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "good morning")
- {
- say("good morning " + eG);
- Console.WriteLine("Uny: Good morning " + eG + "!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Good morning " + eG + "!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "good afternoon")
- {
- say("good afternoon " + eG + "!");
- Console.WriteLine("Uny: Good afternoon " + eG + "!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Good afternoon " + eG + "!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "good evening")
- {
- say("good evening " + eG);
- Console.WriteLine("Uny: Good evening " + eG + "!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: Good evening " + eG + "!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "who is lua")
- {
- say("the main developer of you ni");
- startCRed();
- Console.WriteLine("Uny: The main developer of Uny!");
- endC();
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: The main developer of Uny!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "shut up")
- {
- say("okay, I will shut up!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: Stopping Uny for 10 seconds!" + Environment.NewLine);
- richTextBox1.AppendText("Uny: Okay, I will shut up!" + Environment.NewLine);
- }
- Console.WriteLine("Uny: Okay, I will shut up!");
- await Task.Delay(5000);
- System.Threading.Thread.Sleep(10000);
- say("I will talk now again!");
- Console.WriteLine("Uny: I will talk now again!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: I will talk now again!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "open my playlist")
- {
- dS();
- Console.WriteLine("Uny: *done sound*");
- string link = "https://www.youtube.com/watch?v=HNK1YjheVUA&list=PLTzHfqYskDi9tpH5tte4qeQjOADn1b77J&index=2&t=0s";
- Process.Start("chrome", link);
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: *done sound*" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- if (m == "i am good")
- {
- say("That's nice to hear");
- Console.WriteLine("Uny: That's nice to hear!");
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Uny: That's nice to hear!" + Environment.NewLine);
- }
- await Task.Delay(5000);
- r = null;
- eoc();
- return;
- }
- r = null;
- eoc();
- return;
- }
- }
- }
- else if (r != "hello uny")
- {
- r = null;
- resultString = null;
- }
- }
- }
- private void dS()
- {
- string Soundpath = localPath + @"listenSound.wav";
- System.Media.SoundPlayer player = new System.Media.SoundPlayer(Soundpath);
- player.Play();
- }
- private void listenSound()
- {
- string Soundpath = localPath + @"listenNowSound.wav";
- System.Media.SoundPlayer player = new System.Media.SoundPlayer(Soundpath);
- player.Play();
- }
- private void label3_Click(object sender, EventArgs e)
- {
- }
- private async void pictureBox1_Click(object sender, EventArgs e)
- {
- say("shutting down");
- pictureBox1.Image = Uny.Properties.Resources.Exit_pressed;
- await Task.Delay(1000);
- pictureBox1.Image = Uny.Properties.Resources.Exit;
- Application.Exit();
- }
- private async void pictureBox3_Click(object sender, EventArgs e)
- {
- say("minimizing the UI");
- pictureBox3.Image = Uny.Properties.Resources.minimize_pressed;
- await Task.Delay(500);
- pictureBox3.Image = Uny.Properties.Resources.minimize;
- this.Hide();
- FormActive = 0;
- Console.ForegroundColor = ConsoleColor.Magenta;
- cw("Hiding Uny UI");
- Console.ForegroundColor = ConsoleColor.White;
- }
- private async void pictureBox2_Click(object sender, EventArgs e)
- {
- pictureBox2.Image = Uny.Properties.Resources.fullscreen_pressed;
- if (LogStatus == 1)
- {
- richTextBox1.AppendText("User: " + m + Environment.NewLine);
- richTextBox1.AppendText("Engine: This function is still work in progress!" + Environment.NewLine);
- }
- inWork.Visible = true;
- await Task.Delay(250);
- inWork.Visible = false;
- pictureBox2.Image = Uny.Properties.Resources.Fullscreen;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- public int LogStatus = 0;
- private async void pictureBox5_Click(object sender, EventArgs e)
- {
- if (pictureBox5.Image == staticDeactivated)
- {
- pictureBox5.Image = movingToActivated;
- await Task.Delay(600);
- pictureBox5.Image = staticActivated;
- LogStatus = 1;
- panel4.Visible = true;
- await Task.Delay(3000);
- return;
- }
- if (pictureBox5.Image == staticActivated)
- {
- pictureBox5.Image = movingToDeactivated;
- await Task.Delay(600);
- pictureBox5.Image = staticDeactivated;
- LogStatus = 0;
- panel4.Visible = false;
- return;
- }
- }
- private void Form1_FormClosed(object sender, FormClosedEventArgs e)
- {
- richTextBox1.Visible = false;
- staticActivated.Dispose();
- staticDeactivated.Dispose();
- movingToActivated.Dispose();
- movingToDeactivated.Dispose();
- }
- public string typeCC1;
- public string actionCC1;
- public string callCC1;
- public int existCC1 = 0;
- private void button2_Click(object sender, EventArgs e)
- {
- if(existCC1 == 0)
- {
- int preExist = 0;
- string[] previously = File.ReadAllLines(localPath + @"Config.txt");
- foreach (string x in previously)
- {
- if (x.Contains("CC1@exist") == true)
- {
- preExist = 1;
- }
- }
- AddCC addCC = new AddCC();
- addCC.ShowDialog();
- addCC.Dispose();
- string[] config = File.ReadAllLines(localPath + @"Config.txt");
- foreach (string r in config)
- {
- if (r.Contains("CC1@exist") == true)
- {
- existCC1 = 1;
- Console.WriteLine("Custom Command 1 exists!");
- if (preExist == 0)
- {
- preExist = 1;
- System.Diagnostics.Process.Start(Application.ExecutablePath);
- Application.Exit();
- }
- }
- if (r.Contains("CC1type@") == true)
- {
- typeCC1 = r.Split(Convert.ToChar("@")).Last();
- Console.WriteLine("Type of Custom Command 1: " + typeCC1);
- }
- if (r.Contains("CC1action@") == true)
- {
- actionCC1 = r.Split(Convert.ToChar("@")).Last();
- Console.WriteLine("Action of Custom Command 1: " + actionCC1);
- }
- if (r.Contains("CC1call@") == true)
- {
- callCC1 = r.Split(Convert.ToChar("@")).Last();
- Console.WriteLine("Call of Custom Command 1: " + callCC1);
- }
- }
- } else
- {
- MessageBox.Show("Custom Command 1 already set!");
- }
- }
- private async void panel5_MouseHover(object sender, EventArgs e)
- {
- usernameLabel.Visible = true;
- textBox1.Visible = true;
- if(panel1.Width == 0)
- {
- panel1.Width = 1;
- panel2.Width = 1;
- await Task.Delay(50);
- panel1.Width = 50;
- panel2.Width = 50;
- await Task.Delay(50);
- panel1.Width = 100;
- panel2.Width = 100;
- await Task.Delay(50);
- panel1.Width = 150;
- panel2.Width = 150;
- await Task.Delay(50);
- panel1.Width = 200;
- panel2.Width = 200;
- await Task.Delay(50);
- panel1.Width = 250;
- panel2.Width = 250;
- await Task.Delay(50);
- panel1.Width = 300;
- panel2.Width = 300;
- }
- }
- private void panel5_MouseLeave(object sender, EventArgs e)
- {
- }
- private async void panel6_MouseLeave(object sender, EventArgs e)
- {
- if(panel1.Width == 300)
- {
- panel1.Width = 300;
- panel2.Width = 300;
- await Task.Delay(50);
- panel1.Width = 250;
- panel2.Width = 250;
- await Task.Delay(50);
- panel1.Width = 200;
- panel2.Width = 200;
- await Task.Delay(50);
- panel1.Width = 150;
- panel2.Width = 150;
- await Task.Delay(50);
- panel1.Width = 100;
- panel2.Width = 100;
- await Task.Delay(50);
- panel1.Width = 50;
- panel2.Width = 50;
- await Task.Delay(50);
- panel1.Width = 0;
- panel2.Width = 0;
- panel5.Visible = true;
- usernameLabel.Visible = false;
- textBox1.Visible = false;
- }
- }
- public void startCRed()
- {
- Console.ForegroundColor = ConsoleColor.Red;
- }
- public void endC()
- {
- Console.ForegroundColor = ConsoleColor.White;
- }
- private void button3_Click(object sender, EventArgs e) //WHITESPACE ERROR, PHRASE MAYBE LOOK INTO ADDCC AND CHANG ENVIRONMENT.NEWLINE OR APPENDALLTEXT
- {
- if (MessageBox.Show("Are you sure?", "Confirm deleting CC1", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
- {
- startCRed();
- cw("Deleting in Progress...");
- endC();
- string[] lines = File.ReadAllLines(localPath + "Config.txt");
- List<string> ContentConfig = new List<string>();
- ContentConfig.Add("UN@" + eU);
- foreach (string line in lines)
- {
- if(!line.Contains("CC1") && line != "UN@" + eU)
- {
- ContentConfig.Add(line);
- }
- }
- string[] languageLines = File.ReadAllLines(localPath + "languagePack.txt");
- List<string> ContentPack = new List<string>();
- ContentPack.Add("hey uny");
- foreach (string languageLine in languageLines)
- {
- if (!languageLine.Contains(callCC1) && languageLine != "hey uny" && string.IsNullOrEmpty(languageLine) != true && string.IsNullOrWhiteSpace(languageLine) != true)
- {
- ContentPack.Add(languageLine);
- }
- }
- System.IO.File.WriteAllLines(localPath + @"languagePack.txt", ContentPack);
- System.IO.File.WriteAllLines(localPath + @"Config.txt", ContentConfig);
- if (System.IO.File.Exists(@"C:\Windows\System32\Config.txt"))
- {
- System.IO.File.Delete(@"C:\Windows\System32\Config.txt");
- }
- if (System.IO.File.Exists(@"C:\Windows\System32\languagePack.txt"))
- {
- System.IO.File.Delete(@"C:\Windows\System32\languagePack.txt");
- }
- System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"Config.txt", @"C:\Windows\System32\Config.txt");
- System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"languagePack.txt", @"C:\Windows\System32\languagePack.txt");
- var lastLanguageLines = System.IO.File.ReadAllLines(localPath + @"languagePack.txt");
- System.IO.File.WriteAllLines(localPath + @"languagePack.txt", lastLanguageLines.Take(lastLanguageLines.Length - 1).ToArray());
- var lastConLines = System.IO.File.ReadAllLines(localPath + @"Config.txt");
- System.IO.File.WriteAllLines(localPath + @"Config.txt", lastConLines.Take(lastConLines.Length - 1).ToArray());
- if (System.IO.File.Exists(@"C:\Windows\System32\Config.txt"))
- {
- System.IO.File.Delete(@"C:\Windows\System32\Config.txt");
- }
- if (System.IO.File.Exists(@"C:\Windows\System32\languagePack.txt"))
- {
- System.IO.File.Delete(@"C:\Windows\System32\languagePack.txt");
- }
- System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"Config.txt", @"C:\Windows\System32\Config.txt");
- System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"languagePack.txt", @"C:\Windows\System32\languagePack.txt");
- System.Diagnostics.Process.Start(Application.ExecutablePath);
- Application.Exit();
- }
- else
- {
- startCRed();
- cw("Not deleting!");
- endC();
- }
- }
- private async void button4_Click(object sender, EventArgs e)
- {
- if(atStat == 1)
- {
- RegistryKey rk = Registry.CurrentUser.OpenSubKey
- ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
- rk.DeleteValue("Uny", false);
- atStat = 0;
- button4.Text = "Turn off";
- button4.Visible = false;
- await Task.Delay(3000);
- button4.Visible = true;
- }
- if(atStat == 0)
- {
- RegistryKey rk = Registry.CurrentUser.OpenSubKey
- ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
- rk.SetValue("Uny", Application.ExecutablePath);
- atStat = 1;
- button4.Text = "Turn on";
- button4.Visible = false;
- await Task.Delay(3000);
- button4.Visible = true;
- }
- }
- [DllImport("user32.dll")]
- public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
- private void button5_Click(object sender, EventArgs e)
- {
- const uint WM_KEYDOWN = 0x100;
- const uint WM_KEYUP = 0x0101;
- IntPtr hWnd;
- string processName = "Discord";
- Process[] processList = Process.GetProcesses();
- foreach(Process p in processList)
- {
- if(p.ProcessName.Contains(processName) == true)
- {
- IntPtr edit = p.MainWindowHandle;
- PostMessage(edit, WM_KEYDOWN, (IntPtr)(Keys.Control), IntPtr.Zero);
- PostMessage(edit, WM_KEYDOWN, (IntPtr)(Keys.Enter), IntPtr.Zero);
- PostMessage(edit, WM_KEYUP, (IntPtr)(Keys.Enter), IntPtr.Zero);
- PostMessage(edit, WM_KEYUP, (IntPtr)(Keys.Control), IntPtr.Zero);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement