Пример #1
0
        public void ReadConsole()
        {
            ConsoleText.Text = "";
            Process[] proc = Process.GetProcessesByName(mangosName);
            if (proc.Length == 0)
            {
                ConsoleText.Text = "Error process not found!";
            }
            else
            {
                pPointer = (IntPtr)proc[0].Id;
                HookToConsole.AttachTo(pPointer);

                Point      startPoint = new Point(0, 0);
                Size       recSize    = new Size(75, 5);
                CharInfo[] chars      = HookToConsole.ReadOutput(startPoint, recSize);

                int index = 0;
                foreach (CharInfo ci in chars)
                {
                    if (index != 0 && (index % recSize.Width) == 0)
                    {
                        ConsoleText.Text += "\r\n";
                    }
                    ConsoleText.Text += ci.Char;
                    index++;
                }

                HookToConsole.RemoveFrom();
            }
        }
Пример #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            IntPtr pWindow;

            Process[] proc = Process.GetProcessesByName(mangosName);
            if (proc.Length == 0)
            {
            }
            pPointer = (IntPtr)proc[0].Id;
            pWindow  = (IntPtr)proc[0].MainWindowHandle;
            Win32.SetForegroundWindow(pWindow);
            if (sTimer < Convert.ToDouble(textBox2.Text))
            {
                if (sTimer < (Convert.ToDouble(textBox2.Text) - 1))
                {
                    timeLeft = timeLeft - 1;
                    MainFunctions.SendToConsole("broadcast Server shutting down in: " + timeLeft + " minutes");
                    SendKeys.SendWait("{ENTER}");
                    sTimer++;
                }
                else
                {
                    if (timeLeft == 1)
                    {
                        timeLeft += 0.25;
                    }
                    timer1.Interval = 15000;
                    timeLeft        = timeLeft - 0.25;
                    MainFunctions.SendToConsole("broadcast Server shutting down in: " + (timeLeft * 60) + " seconds");
                    SendKeys.SendWait("{ENTER}");
                    sTimer += 0.25;
                }
            }
            else
            {
                MainFunctions.SendToConsole("exit");
                SendKeys.SendWait("{ENTER}");
                WriteLog("Shutdown counter ended! Shutting down MaNGOS NOW!", Color.Red);
                sTimer         = 0;
                timeLeft       = 5;
                timer1.Enabled = false;
            }
            Win32.SetForegroundWindow(this.Handle);
            HookToConsole.RemoveFrom();
            ReadConsole();
        }
Пример #3
0
        private void button16_Click(object sender, EventArgs e)
        {
            IntPtr pWindow;

            Process[] proc = Process.GetProcessesByName(mangosName);
            if (proc.Length == 0)
            {
            }
            pPointer = (IntPtr)proc[0].Id;
            pWindow  = (IntPtr)proc[0].MainWindowHandle;
            Win32.SetForegroundWindow(pWindow);
            MainFunctions.SendToConsole(textBox6.Text);
            SendKeys.SendWait("{ENTER}");
            Win32.SetForegroundWindow(this.Handle);
            HookToConsole.RemoveFrom();
            ReadConsole();
            WriteLog("Custom command: \"" + textBox6.Text + "\" sent to MaNGOS console!", Color.Blue);
        }
Пример #4
0
        private void button7_Click(object sender, EventArgs e)
        {
            WriteLog("Scripts loaded", Color.Gray);
            IntPtr pWindow;

            Process[] proc = Process.GetProcessesByName(mangosName);
            if (proc.Length == 0)
            {
            }
            pPointer = (IntPtr)proc[0].Id;
            pWindow  = (IntPtr)proc[0].MainWindowHandle;
            Win32.SetForegroundWindow(pWindow);
            MainFunctions.SendToConsole("loadscripts");
            SendKeys.SendWait("{ENTER}");
            Win32.SetForegroundWindow(this.Handle);
            HookToConsole.RemoveFrom();
            ReadConsole();
        }
Пример #5
0
        private void button13_Click(object sender, EventArgs e)
        {
            IntPtr pWindow;

            Process[] proc = Process.GetProcessesByName(mangosName);
            if (proc.Length == 0)
            {
            }
            pPointer = (IntPtr)proc[0].Id;
            pWindow  = (IntPtr)proc[0].MainWindowHandle;
            Win32.SetForegroundWindow(pWindow);
            MainFunctions.SendToConsole("motd " + Convert.ToString(textBox5.Text));
            SendKeys.SendWait("{ENTER}");
            Win32.SetForegroundWindow(this.Handle);
            HookToConsole.RemoveFrom();
            ReadConsole();
            WriteLog("MOTD changed to: " + textBox5.Text, Color.Red);
            textBox6.Text = "";
        }
Пример #6
0
        private void button12_Click(object sender, EventArgs e)
        {
            IntPtr pWindow;

            Process[] proc = Process.GetProcessesByName(mangosName);
            if (proc.Length == 0)
            {
            }
            pPointer = (IntPtr)proc[0].Id;
            pWindow  = (IntPtr)proc[0].MainWindowHandle;
            Win32.SetForegroundWindow(pWindow);
            MainFunctions.SendToConsole("kick " + Convert.ToString(listBox1.SelectedItem));
            SendKeys.SendWait("{ENTER}");
            Win32.SetForegroundWindow(this.Handle);
            HookToConsole.RemoveFrom();
            ReadConsole();
            WriteLog("Account: " + listBox1.SelectedItem + " kicked!", Color.Red);
            button4_Click(null, null);
        }
Пример #7
0
        private void button18_Click(object sender, EventArgs e)
        {
            rStarted = false;

            if (checkBox2.Checked == true)
            {
                if (Process.GetProcessesByName(mangosName).Length > 0)
                {
                    IntPtr    pWindow;
                    Process[] proc = Process.GetProcessesByName(mangosName);
                    pPointer = (IntPtr)proc[0].Id;
                    pWindow  = (IntPtr)proc[0].MainWindowHandle;
                    Win32.SetForegroundWindow(pWindow);
                    MainFunctions.SendToConsole("exit");
                    SendKeys.SendWait("{ENTER}");
                    Win32.SetForegroundWindow(this.Handle);
                    HookToConsole.RemoveFrom();
                    ReadConsole();
                    WriteLog("MaNGOS Restarted Manually!", Color.Red);
                }
                else
                {
                    WriteLog("MaNGOS requested to be restarted, but process not found!", Color.Red);
                }
            }
            if (checkBox3.Checked == true)
            {
                if (Process.GetProcessesByName(realmName).Length > 0)
                {
                    Process[] Proc = Process.GetProcessesByName(realmName);
                    Proc[0].Kill();
                    WriteLog("Realm Restarted Manually!", Color.Red);
                }
                else
                {
                    WriteLog("Realm requested to be restarted, but process not found!", Color.Red);
                }
            }
            restarterButton_Click(null, null);
        }