private void Button3_Click(object sender, EventArgs e)
 {
     PrivateVariable.nospam        = DateTime.Now;
     PrivateVariable.Battling      = false;
     PrivateVariable.InEventScreen = false;
     PrivateVariable.InMainScreen  = false;
     PrivateVariable.InMap         = false;
     BotCore.EjectSockets();
     Variables.ScriptLog("Script Stopped!", Color.White);
     if (Width > 1280)
     {
         Width         -= 1280;
         panel3.Visible = false;
     }
     if (Variables.Proc != null)
     {
         DllImport.SetParent(Variables.Proc.MainWindowHandle, IntPtr.Zero);
         DllImport.MoveWindow(Variables.Proc.MainWindowHandle, PrivateVariable.EmuDefaultLocation.X, PrivateVariable.EmuDefaultLocation.Y, 1318, 752, true);
         Docked = false;
     }
     foreach (Control control in Debug.Controls)
     {
         control.Enabled = true;
     }
     ScriptRun.StopScript();
     btn_Start.Enabled = true;
     Controls.Remove(tp);
 }
示例#2
0
        private void Download_Shown(object sender, EventArgs e)
        {
            DllImport.EnableMenuItem(DllImport.GetSystemMenu(this.Handle, false), 0xF060, 1);
            Thread t = new Thread(() => DownloadFile(url, path));

            t.Start();
        }
示例#3
0
 /// <summary>
 /// Capture image using WinAPI
 /// </summary>
 /// <param name="hWnd"></param>
 /// <param name="cropstart"></param>
 /// <param name="cropend"></param>
 /// <param name="lineNumber"></param>
 /// <param name="caller"></param>
 /// <returns></returns>
 public static ScreenshotData ImageCapture(IntPtr hWnd, Point cropstart, Point cropend, [CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null)
 {
     try
     {
         Stopwatch s  = Stopwatch.StartNew();
         Rectangle rc = new Rectangle();
         DllImport.GetWindowRect(hWnd, ref rc);
         Bitmap   bmp       = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
         Graphics gfxBmp    = Graphics.FromImage(bmp);
         IntPtr   hdcBitmap = gfxBmp.GetHdc();
         DllImport.PrintWindow(hWnd, hdcBitmap, 0);
         gfxBmp.ReleaseHdc(hdcBitmap);
         gfxBmp.Dispose();
         Variables.AdvanceLog("Screenshot saved to memory used " + s.ElapsedMilliseconds + " ms", lineNumber, caller);
         s.Stop();
         bmp = CropImage(bmp, cropstart, cropend, lineNumber, caller);
         if (Variables.ImageDebug)
         {
             bmp.Save("Profiles\\Logs\\" + Encryption.SHA256(DateTime.Now.ToString()) + ".bmp");
         }
         return(Compress(bmp));
     }
     catch
     {
         Instance.captureerror = true;
         return(ImageCapture());
     }
 }
 private void Tp_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         DllImport.ReleaseCapture();
         DllImport.SendMessage(Handle, 0xA1, 0x2, 0);
     }
 }
示例#5
0
        /// <summary>
        /// Capture loop
        /// </summary>

        private void Capt()
        {
            do
            {
                Thread.Sleep(1000);
                if (Variables.Proc != null)
                {
                    if (Variables.Proc.HasExited)
                    {
                        Variables.Proc = null;
                        Docked         = false;
                        continue;
                    }
                    if (Variables.emulator.EmulatorName() == "Nox")
                    {
                        var hide = DllImport.GetAllChildrenWindowHandles(IntPtr.Zero, "Qt5QWindowToolSaveBits", "Form", 2);
                        foreach (var h in hide)
                        {
                            DllImport.ShowWindow(h, 0);
                        }
                    }
                    try
                    {
                        var       handle = Variables.Proc.MainWindowHandle;
                        var       parent = DllImport.GetParent(handle);
                        Rectangle rect   = new Rectangle();
                        DllImport.GetWindowRect(handle, ref rect);
                        if (!Docked)
                        {
                            if (!ScriptRun.Run)
                            {
                                return;
                            }
                            PrivateVariable.EmuDefaultLocation = rect;
                            panel3.Invoke((MethodInvoker) delegate
                            {
                                DllImport.SetParent(Variables.Proc.MainWindowHandle, panel3.Handle);
                            });
                            tp.Invoke((MethodInvoker) delegate { tp.BringToFront(); });
                            Docked = true;
                        }
                        if (rect.X != -1 || rect.Y != -30)
                        {
                            DllImport.MoveWindow(handle, -1, -30, 1318, 752, false);
                        }
                    }
                    catch
                    {
                    }
                }
                else
                {
                    Docked = false;
                }
            } while (ScriptRun.Run);
        }
示例#6
0
        /// <summary>
        /// Capture loop
        /// </summary>

        private void Capt()
        {
            bool Docked = false;

            do
            {
                Thread.Sleep(2000);
                if (Variables.Proc != null)
                {
                    if (Variables.Proc.HasExited)
                    {
                        Variables.Proc = null;
                        Docked         = false;
                        continue;
                    }
                    try
                    {
                        var       handle = Variables.Proc.MainWindowHandle;
                        Rectangle rect   = new Rectangle();
                        DllImport.GetWindowRect(handle, ref rect);
                        if (!Docked)
                        {
                            if (!ScriptRun.Run)
                            {
                                return;
                            }
                            PrivateVariable.Instance.EmuDefaultLocation = rect;
                            panel3.Invoke((MethodInvoker) delegate
                            {
                                DllImport.SetParent(Variables.Proc.MainWindowHandle, panel3.Handle);
                            });
                            tp.Invoke((MethodInvoker) delegate { tp.BringToFront(); });
                            panel3.Invoke((MethodInvoker) delegate
                            {
                                DllImport.SetParent(Variables.Proc.MainWindowHandle, panel3.Handle);
                            });
                            Docked = true;
                        }
                        if (rect.X != -1 || rect.Y != -30)
                        {
                            DllImport.MoveWindow(handle, -1, -30, 1318, 752, false);
                        }
                    }
                    catch
                    {
                    }
                }
                else
                {
                    Docked = false;
                }
            } while (ScriptRun.Run);
        }
        private void MainScreen_Load(object sender, EventArgs e)
        {
            Thread load = new Thread(Loading);

            load.SetApartmentState(ApartmentState.STA);
            load.Start();
            if (!IsRunAsAdministrator())
            {
                var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase)
                {
                    // The following properties run the new process as administrator
                    UseShellExecute = true,
                    Verb            = "runas"
                };
                // Start the new process
                try
                {
                    Process.Start(processInfo);
                }
                catch (Exception)
                {
                    // The user did not allow the application to run as administrator
                    MessageBox.Show("挂机需要权限才能运行!");
                }
                // Shut down the current process
                Application.Exit();
            }
            CheckVersion.CheckUpdate();
            if (!Directory.Exists("Img"))
            {
                File.WriteAllBytes("Img.zip", Img.Images);
                ZipFile.ExtractToDirectory("Img.zip", Environment.CurrentDirectory);
                File.Delete("Img.zip");
            }
            comboBox1.Items.Clear();
            OCR.PrepairOcr(whitelist: "$0123456789", blacklist: "!?@#$%&*()<>_-+=/:;'\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
            Variables.EmulatorPath();
            if (File.Exists("bot.ini"))
            {
                if (File.Exists(Environment.CurrentDirectory + "\\Profiles\\" + BotCore.profilePath + "\\bot.ini"))
                {
                    File.Delete(Environment.CurrentDirectory + "\\Profiles\\" + BotCore.profilePath + "\\bot.ini");
                }
                try
                {
                    File.Copy("bot.ini", Environment.CurrentDirectory + "\\Profiles\\" + BotCore.profilePath + "\\bot.ini", true);
                    File.Delete("bot.ini");
                }
                catch
                {
                }
            }
            Variables.ReadConfig();
            string _NET = Get45PlusFromRegistry();

            if (!Directory.Exists("Language"))
            {
                MessageBox.Show("Lost files, please reinstall the bot!");
                Environment.Exit(0);
            }
            foreach (var lang in Directory.GetFiles("Language"))
            {
                comboBox1.Items.Add(lang.Replace("Language\\", "").Replace(".ini", ""));
            }
            if (Variables.FindConfig("General", "Lang", out string output))
            {
                int index = comboBox1.Items.IndexOf(output);
                if (index < 0)
                {
                    comboBox1.SelectedIndex = 0;
                }
                else
                {
                    comboBox1.SelectedIndex = index;
                }
            }
            else
            {
                comboBox1.SelectedIndex = 0;
            }
            label3.Text = Variables.VBoxManagerPath;
            label4.Text = Variables.SharedPath;
            if (Variables.FindConfig("General", "Level", out output))
            {
                switch (output)
                {
                case "0":
                    chk_begin.Checked = true;
                    break;

                case "1":
                    chk_inter.Checked = true;
                    break;

                case "2":
                    chk_advan.Checked = true;
                    break;

                case "3":
                    chk_extre.Checked = true;
                    break;

                case "4":
                    chk_ultim.Checked = true;
                    break;
                }
            }
            else
            {
                Variables.ModifyConfig("General", "Level", "0");
            }
            if (Variables.FindConfig("General", "Double_Event", out output))
            {
                if (output == "true")
                {
                    chk_twoE.Checked = true;
                }
            }
            if (Variables.FindConfig("General", "Manual_Rune", out output))
            {
                if (output == "true")
                {
                    chk_manuRT.Checked = true;
                }
            }
            if (Variables.FindConfig("General", "Suspend_PC", out output))
            {
                if (output == "true")
                {
                    Suspend_Chk.Checked = true;
                }
            }
            if (Variables.FindConfig("General", "biubiu", out output))
            {
                if (output == "true")
                {
                    Biubiu.Checked = true;
                }
            }
            if (Variables.FindConfig("General", "ArWiEv", out output))
            {
                if (output == "true")
                {
                    Chk_Archwitch.Checked = true;
                }
            }
            if (Variables.FindConfig("General", "SoWeEv", out output))
            {
                if (output == "true")
                {
                    Chk_SoulWeapon.Checked = true;
                }
            }
            if (Variables.FindConfig("General", "ArWiSt", out output))
            {
                string temp = output.Replace(".", "-");
                Combo_Archwitch.SelectedItem = temp;
            }
            else
            {
                Combo_Archwitch.SelectedIndex = 0;
            }
            if (Variables.FindConfig("General", "SoWeSt", out output))
            {
                string temp = output.Replace(".", "-");
                Combo_Weapon.SelectedItem = temp;
            }
            else
            {
                Combo_Weapon.SelectedIndex = 0;
            }
            if (Variables.ForceWinApiCapt)
            {
                WinAPi.Checked = true;
                WinAPi.Enabled = false;
            }
            else
            {
                if (Variables.FindConfig("General", "WinApi", out output))
                {
                    if (output == "true")
                    {
                        WinAPi.Checked = true;
                    }
                }
            }
            if (Variables.FindConfig("GuildWar", "Manual", out output))
            {
                if (output == "true")
                {
                    chk_GWW.Checked = true;
                }
            }
            if (Variables.FindConfig("Version", "Version", out output))
            {
                if (output != CheckVersion.currentVersion)
                {
                    CheckVersion.UpdateText = "# Thanks for supporting VCBot! \n" + CheckVersion.BufferUpdateText;
                    Variables.ModifyConfig("Version", "Version", CheckVersion.currentVersion);
                }
            }
            else
            {
                CheckVersion.UpdateText = "# Thanks for supporting VCBot! \n" + CheckVersion.BufferUpdateText;
                Variables.ModifyConfig("Version", "Version", CheckVersion.currentVersion);
            }
            webBrowser1.ScriptErrorsSuppressed = true;
            webBrowser3.ScriptErrorsSuppressed = true;
            PrivateVariable.nospam             = DateTime.Now;
            string ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36";

            DllImport.UrlMkSetSessionOption(DllImport.URLMON_OPTION_USERAGENT, ua, ua.Length, 0);
            webBrowser3.Navigating += OnNavigating;
            webBrowser3.Navigated  += WebBrowser3_Navigated;
            GetEventXML.LoadXMLEvent();
            webBrowser3.Navigate(new Uri("http://www-valkyriecrusade.nubee.com/" + GetEventXML.Eventlink.Replace("/en/", "/" + comboBox1.SelectedItem.ToString() + "/") + ".html"));
            VCBotScript.Read_Plugins();
            foreach (var s in PrivateVariable.BattleScript)
            {
                tabControl2.TabPages.Add(s.ScriptName());
                tabControl2.TabPages[tabControl2.TabPages.Count - 1].BackColor = Color.Black;
                tabControl2.TabPages[tabControl2.TabPages.Count - 1].ForeColor = Color.White;
                CheckBox chk = new CheckBox
                {
                    Text    = "使用脚本",
                    Checked = false
                };
                chk.CheckedChanged += Chk_CheckedChanged;
                chk.Location        = new Point(10, 250);
                chk.AutoSize        = true;
                tabControl2.TabPages[tabControl2.TabPages.Count - 1].Controls.Add(chk);
                customScriptEnable.Add(chk);
                foreach (var c in s.CreateUI())
                {
                    tabControl2.TabPages[tabControl2.TabPages.Count - 1].Controls.Add(c);
                }
            }
            if (Variables.FindConfig("General", "Selected_Script", out string n))
            {
                try
                {
                    int i = Convert.ToInt32(n);
                    if (i > customScriptEnable.Count)
                    {
                        i = 0;
                    }
                    customScriptEnable[i].Checked = true;
                }
                catch
                {
                    customScriptEnable[0].Checked = true;
                }
            }
            else
            {
                customScriptEnable[0].Checked = true;
            }
            if (GetEventXML.RandomImage != null)
            {
                var request = WebRequest.Create("http://www-valkyriecrusade.nubee.com/" + GetEventXML.RandomImage);
                using (var response = request.GetResponse())
                    using (var stream = response.GetResponseStream())
                    {
                        pictureBox4.Image = Image.FromStream(stream);
                    }
            }
            foreach (Control box in ED_Box.Controls)
            {
                foreach (Control control in box.Controls)
                {
                    control.MouseDown += Tp_MouseDown;
                }
                box.MouseDown += Tp_MouseDown;
            }
            ED_Box.MouseDown += Tp_MouseDown;
            metroTabControl1.SelectedIndex = 0;
            chk_item.Enabled        = chk_autoRT.Checked;
            Login.LoadCompleted     = true;
            PrivateVariable.VCevent = PrivateVariable.EventType.Unknown;
            timer2.Start();
        }
示例#8
0
 /// <summary>
 /// Send a mouse click to location
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public static void DoMouseClick(int x, int y)
 {
     //Call the imported function with the cursor's current position
     DllImport.mouse_event(DllImport.MOUSEEVENTF_LEFTDOWN | DllImport.MOUSEEVENTF_LEFTUP, x, y, 0, 0);
 }
示例#9
0
 /// <summary>
 /// Send a mouse click to location
 /// </summary>
 /// <param name="location"></param>
 public static void DoMouseClick(Point location)
 {
     //Call the imported function with the cursor's current position
     DllImport.mouse_event(DllImport.MOUSEEVENTF_LEFTDOWN | DllImport.MOUSEEVENTF_LEFTUP, location.X, location.Y, 0, 0);
 }