Program Crashing. menu

User Tag List

Results 1 to 12 of 12
  1. #1
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Program Crashing.

    Ok, i made myself this little program that does some different stuff in Wow. But when i run it and target WoW it crashes and just keeps shooting. Its really annoying that my little "bot" attacks everything that walks by because my program crashes. Its a simple little program, a bit messy i know, but it works :P

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace Attackroutine1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                this.KeyPreview = true;
    
                this.KeyUp += new KeyEventHandler(Form1_KeyUp);
                this.KeyUp += new KeyEventHandler(Form1_Keyuo);
            }
    
            private void button3_Click(object sender, EventArgs e) // Follow Knap
            {
                System.Threading.Thread.Sleep(2000);
                SendKeys.Send("{Enter}"+ "/follow"+ "{Enter}");
            }
    
            private void button4_Click(object sender, EventArgs e) // Enter BG Kanal
            {
                System.Threading.Thread.Sleep(2000);
                SendKeys.Send("{Enter}" + "/bg" + "{Enter}");
            }
    
            private void button5_Click(object sender, EventArgs e) // Enter Raid Kanal
            {
                System.Threading.Thread.Sleep(2000);
                SendKeys.Send("{Enter}" + "/raid" + "{Enter}");
            }
    
            private void button2_Click(object sender, EventArgs e) // Rutine Start
            {
                System.Threading.Thread.Sleep(2000);
                Rutine.Start();
            }
    
            private void button8_Click(object sender, EventArgs e) // Rutine Stop
            {
                Rutine.Stop();
            }
    
            private void button1_Click(object sender, EventArgs e) // Anti-AFK
            {
                while (true)
                {
                    System.Threading.Thread.Sleep(2000);
                    SendKeys.Send("w" + "w" + "w" + "w" + "s" + "s" + "s" + "s");
                }
            }
    
            private void Rutine_Tick(object sender, EventArgs e) // Rutine
            {
                System.Threading.Thread.Sleep(2000);
                while (true)
                {
                SendKeys.Send("4");
                System.Threading.Thread.Sleep(1500);
                SendKeys.Send("2");
                System.Threading.Thread.Sleep(1500);
                    SendKeys.Send("5");
                    System.Threading.Thread.Sleep(1500);
                        SendKeys.Send("5");
                    System.Threading.Thread.Sleep(1500);
                            SendKeys.Send("5");
                System.Threading.Thread.Sleep(1500);
                                SendKeys.Send("4");
                                    System.Threading.Thread.Sleep(1500);
                                    SendKeys.Send("2");
                                        System.Threading.Thread.Sleep(1500);
                                        SendKeys.Send("5");
                                            System.Threading.Thread.Sleep(1500);
                                            SendKeys.Send("5");
                                                System.Threading.Thread.Sleep(1500);
                                                SendKeys.Send("5");
    
                }
            }
    
            void Form1_KeyUp(object sender, KeyEventArgs e)
            {
    
                if (e.KeyCode == Keys.F5)
                {
                    Rutine.Start();
                }
    
            }
    
            void Form1_Keyuo(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.F6)
                {
                    Rutine.Stop();
                }
            }
    
            private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                Rutine.Start();
            }
    
            private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                Rutine.Stop();
            }
    
        }
    }
    Picture:



    I know, its Danish, but it shouldnt be a problem. Its a simple little program, its top Most and only 40 % visible, so that i can have it running while playing WoW. I dont know why its so damn unstable.. :-/ Was hoping for some help ^^

    - Krillere

    Program Crashing.
  2. #2
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
                while (true)
                {
                SendKeys.Send("4");
                System.Threading.Thread.Sleep(1500);
                SendKeys.Send("2");
                System.Threading.Thread.Sleep(1500);
                    SendKeys.Send("5");
                    System.Threading.Thread.Sleep(1500);
                        SendKeys.Send("5");
                    System.Threading.Thread.Sleep(1500);
                            SendKeys.Send("5");
                System.Threading.Thread.Sleep(1500);
                                SendKeys.Send("4");
                                    System.Threading.Thread.Sleep(1500);
                                    SendKeys.Send("2");
                                        System.Threading.Thread.Sleep(1500);
                                        SendKeys.Send("5");
                                            System.Threading.Thread.Sleep(1500);
                                            SendKeys.Send("5");
                                                System.Threading.Thread.Sleep(1500);
                                                SendKeys.Send("5");
    
                }
    Once this code is reached you're stuck in a while loop that sleeps the mainthread forever. And sleep really means sleep.

    Possible fix: Execute that routine in another thread.

    *awaits Apoc*

  3. #3
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You really need to learn how to use threading.

    Code:
    		private void RunRoutine()
    		{
    			// Don't use while(true).
    			for (;;)
                {
    				System.Threading.Thread.Sleep(2000);
    				SendKeys.Send("4");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("2");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("5");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("5");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("5");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("4");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("2");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("5");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("5");
    				System.Threading.Thread.Sleep(1500);
    				SendKeys.Send("5");
                }
    		}
    		
    		private System.Threading.Thread routineThread;
            private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                //Rutine.Start();
    			// Run the routine on a SEPARATE THREAD.
    			routineThread = new Thread(RunRoutine);
    			routineThread.IsBackground = true;
    			routineThread.Start();
            }
    
            private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                //Rutine.Stop();
    			routineThread.Abort();
            }
    If you run your code with all those sleeps, you'll make your GUI unresponsive. (Especially the infinite loops)

  4. #4
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah. So, when i do the
    Code:
    While (true)
    {Code lawl lawl}
    It crashes because i make the program sleep in a ever lasting loop? Then how should i make a loop that wont kill my program if i sleep? :-)

    Edit: Ok, i think i understand some of it now, you want me to make it in a new thread, and when you say thread, do you mean open another Code File in Visual Studio?

    Edit Edit: Thanks alot guys. I PM'ed SKU and he helped me alot, now i got a last question, the
    Code:
    for(; ; )
    How does that works? What is the (; ; ) part for? I dont quite understand that loop type :P
    Last edited by Krillere; 03-21-2009 at 11:29 AM.

  5. #5
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Threading Tutorial (C#)

    Please read that.

    Also, the ( ;; ) is just like a for loop's regular syntax. Just ommiting any reason for it to do any work. (Same function as while(true) except it's more grammatical to use the for( ;; ) to show you actually mean to use an infinite loop.)

  6. #6
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. Thanks, my program works now :-) SKU really helped me alot when i PM'ed him before. Thanks for helping me again.

  7. #7
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wait. I have a new question. The Domainupdown item, i wrote some different things in it and i want something to happen when i choose one. I have been looking at some codes snippets on google but thoose seem long and hard. If any of you got a little projekt then please show me :-)

    *Awaits SKU and Apoc*

  8. #8
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doubleclick the domainUpDown control (or manually add the event), then do something like this:
    Code:
            private void Form1_Load(object sender, EventArgs e)
            {
                AddStrings();
            }
    
            /// <summary>
            /// Add some strings to the DomainUpDown control.
            /// </summary>
            private void AddStrings()
            {
                domainUpDown1.Items.Add("a");
                domainUpDown1.Items.Add("b");
                domainUpDown1.Items.Add("c");
            }
    
            /// <summary>
            /// Fires when the selected item of the domainUpDown control changes.
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void domainUpDown1_SelectedItemChanged(object sender, EventArgs e)
            {
                string curString = domainUpDown1.SelectedItem.ToString();
                switch (curString)
                {
                    case "a":
                        // do something
                        MessageBox.Show("Hi thar.");
                        break;
                    case "b":
                        // do something different
                        this.Text = "Wut wut";
                        break;
                    case "c":
                        // and the 3rd string
                        this.Opacity = 0.5;
                        break;
                    default:
                        break;
                }
            }

  9. #9
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simply put, don't use the DomainUpDown control. Use a combobox.

    I've never seen a reason to use the DomainUpDown control over the ComboBox control... ever. Not only do you have to add 'error' code due to the way DomainUpDown controls work (you have to account for the fact that the user can never 'skip' a value) but it's also clumsy to work with if you have a lot of values.

  10. #10
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. ComboBox. Just gonna try find out how that works.. But thanks ;P

    Edit: You got a code snippet that shows how a ComboBox works with a button? Google is my enemy..

  11. #11
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Krillere View Post
    Ok. ComboBox. Just gonna try find out how that works.. But thanks ;P

    Edit: You got a code snippet that shows how a ComboBox works with a button? Google is my enemy..
    Code:
    public void button1_Click(object sender, EventArgs e)
    {
        if (comboBox1.SelectedItem != null)
        {
            MessageBox.Show(comboBox1.SelectedItem.ToString());
        }
    }
    Wrote that in the browser, so excuse me if it's wrong. :P

  12. #12
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks. Gonna have a look into it.
    Code:
    If (comboBox1.SelectedItem != null)
    the Null, do i change it to whatever i wrote in the ComboBox? :S

Similar Threads

  1. [Question] C# EasyHook calling the original function crashes the program
    By chronicxo in forum WoW Bots Questions & Requests
    Replies: 0
    Last Post: 12-20-2016, 09:05 AM
  2. Hijacked Program crashes
    By alkololl in forum Programming
    Replies: 0
    Last Post: 03-05-2014, 10:21 AM
  3. [Question] C Program crashes after malloc
    By d3rrial in forum Programming
    Replies: 7
    Last Post: 04-19-2012, 04:44 PM
  4. Am I being hacked with some sort of client crash program/bot?
    By Tudtud in forum World of Warcraft General
    Replies: 1
    Last Post: 03-17-2011, 01:10 PM
  5. Replies: 24
    Last Post: 07-04-2008, 06:01 PM
All times are GMT -5. The time now is 06:45 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search