Spambot repeat part won't spam fast - c#

I'm working on a spambot but there is 1 problem I can't solve. I made buttons you can press, it says how much you want to spam. If you want to spam you will get a certain amount of time to go to the place where you want to spam. I made a function for how much the text will spam. But the problem is when it send 1 message it wait the certain amount of time time and not the 500 miliseconds
The script is written in C#. The target framework is: .NET Framework 4.6.1.
public partial class Form1 : Form
{
public void Time()
{
for (int i = 0; i <= 10;)
{
Stuur();
i++;
}
} // 10x
public void Stuur() // does the sending
{
System.Threading.Thread.Sleep(500);
SendKeys.Send(textBox3.Text);
SendKeys.Send("{ENTER}");
}
public Form1()
{
InitializeComponent();
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Rush B", "5 sec voor spam",
MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Threading.Thread.Sleep(5000);
Time();
}
private void button2_Click(object sender, EventArgs e) // the credit
block
{
if (textBox6.Visible == true)
{
textBox6.Visible = false;
} else {
textBox6.Visible = true;
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}

Maybe something along these lines?
public void Stuur() // does the sending
{
System.Threading.Thread.Sleep(5000);
SendKeys.Send(textBox3.Text);
SendKeys.Send("{ENTER}");
}
public Form1()
{
InitializeComponent();
}
private void textBox4_TextChanged(object sender, EventArgs e) { }
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i <= Int32.Parse(textBox.Text4); i++) {
Stuur();
}
}
private void button2_Click(object sender, EventArgs e) // the credit block
{
if (textBox6.Visible == true)
{
textBox6.Visible = false;
}
else
{
textBox6.Visible = true;
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e) { }
}
edit: closed parenthesis

Related

How to avoid user being able to create a Double Booking in a database?

Basically I would like to stop my system from allowing the user to be able to create multiple bookings under the same time slot for a booking if that makes sense. My system basically allows a user to make a booking for a walk, and ideally each walk should only be able to be booked from Monday to Sunday during working hours, but a slot should be 1.5 hours each but at the moment, there is no slots, just the date time pickers for the time and date of the booking and for multiple bookings the user can just pick the same time so i do want to get that fixed.
Hopefully this helps- I have attached my code for my "add booking" form so hopefully thats of some use.
public partial class AddBooking : Form
{
private int count;
private Boolean IsEmpty = false;
private static string _connectionstring = ConfigurationManager.ConnectionStrings["DoggieConnectionString"].ConnectionString;
public AddBooking()
{
InitializeComponent();
CenterToScreen();
GenerateBookingNumber();
IDDisplay.Text = "" + count;
dateTimePicker2.Format = DateTimePickerFormat.Custom;
dateTimePicker2.CustomFormat = "HH:mm tt";
dateTimePicker2.ShowUpDown = true;
DateTime now = DateTime.Now;
}
private void AddBooking_Load(object sender, EventArgs e)
{
}
private int GenerateBookingNumber()
{
string smt = "SELECT COUNT(*) FROM dbo.Booking";
count = 0;
using (SqlConnection connection = new SqlConnection(_connectionstring))
{
using (SqlCommand cmdCount = new SqlCommand(smt, connection))
{
connection.Open();
count = (int)Convert.ToInt32(cmdCount.ExecuteScalar());
}
}
count = count + 4;
return count;
}
private void PresenceCheck()
{
if (string.IsNullOrEmpty(WalkLocationtxt.Text) || string.IsNullOrEmpty(StaffIDtxt.Text))
{
IsEmpty = true;
}
else
{
IsEmpty = false;
}
}
private void SubmitInfobtn_Click(object sender, EventArgs e)
{
// MessageBox.Show("welcome " + dateTimePicker1.Value.ToShortDateString());
// MessageBox.Show("Goodddd" + dateTimePicker2.Value.ToShortTimeString());
PresenceCheck();
if (IsEmpty == false)
{
int rowsareaffected = ClassDatabase.AddBookingDetails(Convert.ToInt32(IDDisplay.Text), dateTimePicker1.Value.ToShortDateString(), dateTimePicker2.Value.ToShortTimeString(), Convert.ToInt32(StaffIDtxt.Text), WalkLocationtxt.Text);
if (rowsareaffected > 0)
{
MessageBox.Show("New Booking Added Sucessfully", "Sucess!", MessageBoxButtons.OK, MessageBoxIcon.Information);
StaffIDtxt.Clear();
WalkLocationtxt.Clear();
GenerateBookingNumber();
IDDisplay.Text = "" + count;
}
else
{
MessageBox.Show("An Error Occurred", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
}
private void mENUToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void returnToMenuToolStripMenuItem_Click(object sender, EventArgs e)
{
new MenuScreen().Show();
this.Close();
}
private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
{
new LoginScreen().Show();
this.Close();
}
private void exitSystemToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult Result = MessageBox.Show("Are you sure you want to Exit the JD Dog Care Program?", "Are You Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
if (Result == DialogResult.Yes)
{
Application.Exit();
}
else
{
}
}
private void addClientToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddClient().Show();
this.Close();
}
private void manageClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewClient().Show();
this.Close();
}
private void addDogsToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddDog().Show();
this.Close();
}
private void manageDogsToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewDog().Show();
this.Close();
}
private void addStaffToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddStaff().Show();
this.Close();
}
private void manageStaffToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewStaff().Show();
this.Close();
}
private void addBookingToolStripMenuItem_Click(object sender, EventArgs e)
{
new AddBooking().Show();
this.Close();
}
private void manageBookingToolStripMenuItem_Click(object sender, EventArgs e)
{
new ViewBooking().Show();
this.Close();
}
private void addDogToBookingToolStripMenuItem_Click(object sender, EventArgs e)
{
new DogToWalk().Show();
this.Close();
}
}
}

How could I check if progress bar is full and then open an .bat file?

I don't know exactly where the code should be put and what code should look like. I need help, because I am very new to c#
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
this.timer1.Start();
}
private void Timer1_Tick(object sender, EventArgs e)
{
this.progressBar1.Increment(1);
}
private void Form1_Load(object sender, EventArgs e)
{
this.TopMost = true;
}
private void ProgressBar1_Click(object sender, EventArgs e)
{
}
}
}
When I try the method from old videos, there is no such a thing as it and it shows that progressBar1 doesn't exist.
private void Timer1_Tick(object sender, EventArgs e)
{
this.progressBar1.Increment(1);
If (progressBar1.Value >= progressBar1.Maximum)
{
// do something
}
}
Just compare the progressBar1.Value
// progressBar1.Value = 0;
// progressBar1.Minimum = 0;
// progressBar1.Maximum = 100;
private void Timer1_Tick(object sender, EventArgs e)
{
this.progressBar1.Increment(1);
if(progressBar1.Value == progressBar1.Maximum){
Process.Start("c:\\file.bat");
}
}

Xamarin - Morse code app usuing the flaslight

I am trying to make a morse code for a college project, what I'm trying to do is use a 2 dimensional array to save the morse code people input to a text file and then be able to load it from the text file, my logic was to was that within the array was this array[morse name][morse input]. what I need to figure out first is how to send data from methods / buttons OBtn_Clicked , LBtn_Clicked, SBtn_Clicked and EndBtn_Clicked to NewMorseBtn_Clicked to add into the array which will then write it out to a text file I've created.
namespace FlashLightApp2018
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MorsePage : ContentPage
{
//bool exitLoop = false;
public MorsePage()
{
InitializeComponent();
}
private async void NewMorseBtn_Clicked(object sender, EventArgs e)
{
bool isTextEmpty = String.IsNullOrEmpty(MorseName.Text);
if (isTextEmpty)
{
}
else
{
OBtn.IsEnabled = true;
LBtn.IsEnabled = true;
SBtn.IsEnabled = true;
EndBtn.IsEnabled = true;
// String morseName = MorseName.Text;
//String[,] morseSave = new String[100,100];
}
//File.WriteAllText(morseName, text);
//while (exitLoop != true)
//{
//}
}
private void LoadMorseBtn_Clicked(object sender, EventArgs e)
{
}
private void PlayMorseBtn_Clicked(object sender, EventArgs e)
{
}
private void OBtn_Clicked(object sender, EventArgs e)
{
}
private void LBtn_Clicked(object sender, EventArgs e)
{
}
private void SBtn_Clicked(object sender, EventArgs e)
{
}
private void EndBtn_Clicked(object sender, EventArgs e)
{
}
}
}
first, declare you data at the class level (outside of a single method) so that it is accessible from throughout your class
string morseData = string.Empty;
then have your different button methods update the data
private void OBtn_Clicked(object sender, EventArgs e)
{
morseData += ".";
}
private void LBtn_Clicked(object sender, EventArgs e)
{
moreseData += "-";
}

Not returning elapsed time in milliseconds

I've built this simple stopwatch program to measure time in the format of: 00:00:000 [minutes:seconds:milliseconds], but the code ignores the format and counts up like this: 00:00:[seconds here][milliseconds here], so as a result I can only get the elapsed time in 10s of milliseconds and not the individual millisecond.
Here's the display:
The actual time elapsed is 3 seconds and 610 milliseconds.
Code:
namespace stopwatch_1
{
public partial class Form1 : Form
{
int timeMinutes, timeSeconds, timeMSeconds;
bool timerActive;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
resetTime();
}
private void buttonStart_Click(object sender, EventArgs e)
{
timerActive = true;
}
private void buttonStop_Click(object sender, EventArgs e)
{
timerActive = false;
}
private void buttonReset_Click(object sender, EventArgs e)
{
resetTime();
}
private void resetTime()
{
timerActive = false;
timeMinutes = 0;
timeSeconds = 0;
timeMSeconds = 0;
}
private void timerStopwatch_Tick(object sender, EventArgs e)
{
if (timerActive == true)
{
timeMSeconds++;
if (timeMSeconds >= 1000)
{
timeMSeconds = 0;
timeSeconds++;
if (timeSeconds >= 60)
{
timeSeconds = 0;
timeMinutes++;
}
}
}
timerDraw();
}
private void timerDraw()
{
labelMinutes.Text = String.Format("{0:00}", timeMinutes);
labelSeconds.Text = String.Format("{0:00}", timeSeconds);
labelMSeconds.Text = String.Format("{0:000}", timeMSeconds);
}
}
}`
The timer interval is set to one, and I've double checked that all variables are pointing to the right labels so I think the problem lies with where I've formatted the string to display, but I'm not sure where I've gone wrong:
private void timerDraw()
{
labelMinutes.Text = String.Format("{0:00}", timeMinutes);
labelSeconds.Text = String.Format("{0:00}", timeSeconds);
labelMSeconds.Text = String.Format("{0:000}", timeMSeconds);
}
I don't really know how to use string.format in this context, so this is probably where I've gone wrong, all help would be appreciated
The Windows Forms Timer component is single-threaded, and is limited to an accuracy of 55 milliseconds.
You should use a Stopwatch to get a more accurate resolution:
Stopwatch stopwatch;
public Form1()
{
InitializeComponent();
stopwatch = new Stopwatch();
}
private void Form1_Load(object sender, EventArgs e)
{
// do nothing
}
private void buttonStart_Click(object sender, EventArgs e)
{
stopwatch.Start();
}
private void buttonStop_Click(object sender, EventArgs e)
{
stopwatch.Stop();
}
private void buttonReset_Click(object sender, EventArgs e)
{
stopwatch.Reset();
}
private void timerStopwatch_Tick(object sender, EventArgs e)
{
timerDraw();
}
private void timerDraw()
{
labelMinutes.Text = String.Format("{0:00}", stopwatch.Elapsed.Minutes);
labelSeconds.Text = String.Format("{0:00}", stopwatch.Elapsed.Seconds);
labelMSeconds.Text = String.Format("{0:000}", stopwatch.Elapsed.Milliseconds);
}
EDIT:
You should also reduce the Interval on your timer, since there is no need to refresh the labels on a 1ms interval anymore.

c# winforms button and richtextbox

I made ​​a winform with 1 richtextbox and two buttons,
and I hope that when I click on the yes button , it will show a method soal2 in richtextbox1 , and then when I click again it will show soal3 , how to do that?
this is my design
public void soal1()
{
richTextBox1.Text = "Hemofilia is xxxxx";
}
public void soal2()
{
richTextBox1.Text = "xxxxxxx";
}
public void soal3()
{
richTextBox1.Text = "yyyyyy";
}
private void Quiz1_Load(object sender, EventArgs e)
{
soal1();
}
private void button1_Click(object sender, EventArgs e)
{
}
/* ... */
bool alreadyShownSoal2 = false;
private void button1_Click(object sender, EventArgs e)
{
if(alreadyShownSoal2)
soal3();
else
soal2();
alreadyShownSoal2 = true;
}
or
/* ... */
bool alreadyShownSoal2 = false;
public void soal2()
{
if(alreadyShownSoal2)
soal3();
else
richTextBox1.Text = "xxxxxxx";
alreadyShownSoal2 = true;
}
/* ... */
private void button1_Click(object sender, EventArgs e)
{
soal2();
}
This is an absolutely terrible design, but unless you give more specifications... it'd definitely do what you are asking

Categories

Resources