I Want To Make A Automated Key Presser For A Game - c#

hi i want to make a program that presses ctrl + v every 130 secs but it didnt worked for games (it worked for google, notepad etc.) i tried this code down below before
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TradeChatBot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void start_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void stop_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
SendKeys.Send("^{v}");
SendKeys.Send("{ENTER}");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}

You can look into Clipboard class. https://msdn.microsoft.com/en-Us/library/system.windows.forms.clipboard(v=vs.110).aspx
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text= "SendKeys.Send(^{v}); ";
Clipboard.SetText(textBox1.Text);
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Focus();
SendKeys.Send("^{v}");
SendKeys.Send("{ENTER}");
}

Related

how do i link my windows form with .NET framework to steam without build errors

It says I have two build errors which I do not know how to fix for some reason. Please help me as I am trying to build a desktop control center for myself. It is also not linking the steam button to steam(yes, I did put steam.exe and the file path, but I get errors still.). The photo below is a photo of my code and what the application looks like.code and what the actual application looks like!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace my_app
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void MyForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.Shift && e.KeyCode == Keys.O)
{
// Your code when shortcut Ctrl+Shft+O is pressed
InitializeComponent();
}
}
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("www.google.com");
Application.Exit();
}
private void button2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("www.netflix.com");
Application.Exit();
}
private void button3_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("spotify.exe");
Application.Exit();
}
private void button4_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("discord:display");
//System.Diagnostics.Process.Start("discord.exe");
Application.Exit();
}
private void button5_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/Apexofacircle/TheApexOfAAgent");
Application.Exit();
}
private void button6_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("steam.exe");
Application.Exit();
}
}
}
First you need to find the path to the target file:
Below I make a simple demonstration:
private void button2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(#"C:\Users\Administrator\Desktop\TEST.docx");
}
When you run Notepad (Start > Run > Notepad) how does the OS know that Notepad.exe lives in the System32 folder? It finds it because the path C:\Windows\System32 is in the PATH environment variable, which tells the OS where to look for executables.
Similarly, put the path where steam.exe lives in the Path:

CS0501 error in Visual Studio 2017

So I have been coding C# for a few days, making a Roblox Exploit. I am making a drop down menu for my exploit, using timer ticks and it says "CS0501 C# must declare a body because it is not marked abstract, extern, or partial". I am a newbie at C# so I searched the problem up and I am not able to figure out why this problem is occurring. The code is down below. Please help, and if so, put down the code so I can just see what was my problem! Thanks!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeAreDevs_API;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public void LuaTimer_Tick(EventArgs e, object sender);
private ExploitAPI wolfapi = new ExploitAPI();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
wolfapi.LaunchExploit();
}
private void buttonKill_Click(object sender, EventArgs e)
{
string target = usernameTarget.Text;
wolfapi.DoKill(target);
}
private void button1_Click_1(object sender, EventArgs e)
{
string target = usernameTarget.Text;
int speedValue = Int32.Parse(SpeedValue.Text);
wolfapi.SetWalkSpeed(target, speedValue);
}
private void button3_Click(object sender, EventArgs e)
{
string target = usernameTarget.Text;
wolfapi.TeleportMyCharacterTo(target);
}
private void speedValue_TextChanged(object sender, EventArgs e)
{
}
private void updateButton_Click(object sender, EventArgs e)
{
wolfapi.IsUpdated();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void button1_Click_2(object sender, EventArgs e)
{
string script = luaExecutor.Text;
wolfapi.SendLimitedLuaScript(script);
}
private void luaC_Click(object sender, EventArgs e)
{
string script = luaExecutor.Text;
wolfapi.SendScript(script);
}
private void noDoors_Click(object sender, EventArgs e)
{
}
private void luaExecutor_TextChanged(object sender, EventArgs e)
{
}
private void luaPanel_Paint(object sender, PaintEventArgs e)
{
}
private void luaOpen_Click(object sender, EventArgs e)
{
}
private void LuaTimer_Tick_1(object sender, EventArgs e)
{
}
}
}
Well,
public void LuaTimer_Tick(EventArgs e, object sender);
is a method without body, so you should either implement it:
public void LuaTimer_Tick(EventArgs e, object sender) {
//TODO: put relevant code here
}
or, technically, you can mark it as abstract (do not forget to mark class with abstract as well: public abstract partial class Form1 : Form {...})
public abstract void LuaTimer_Tick(EventArgs e, object sender);

The process cannot access the file because it is being used by another process” Windows Application Development

I have seen similar questions however the answers didn't help me out. I am coding a basic windows application using c#. This is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Practice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Main main = new Main();
main.Show();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}
}
I don't know what I am doing wrong.
Main is a second window that is opened.
The other methods are there because I would have double clicked by mistake.
The following code solved my problem:
private void button2_Click(object sender, EventArgs e)
{
Main main = new Main();
this.Hide();
main.ShowDialog();
this.Close();
}
The problem as some of the people that tried to help was that due to the this.Hide() the program was still being executed even though I pressed the close (x) button.
But now with the above code the form is closed and no background processes are running after the app is closed.

In C#, wait for browser to finish load then start a timer

I am trying to find out how I can enable a timer and set its interval to 1000 when the webpage is finished loading.
Here is the code I've tried with so far:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("website.com");
webBrowser1.ScriptErrorsSuppressed = true;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("brukernavn")[0].SetAttribute("value", textBox1.Text);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("passord")[0].SetAttribute("value", textBox2.Text);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("login_buton")[0].InvokeMember("click");
timer1.Enabled = true;
timer1.Interval = 7000;
}
private void timer1_Tick(object sender, EventArgs e)
{
webBrowser1.Navigate("website.com/mygambling.php");
//Here I need a code to enable timer2 with interval 1000 when the website is finished loading
}
private void timer2_Tick(object sender, EventArgs e)
{
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", 250);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
}
}
}
So my question is how can I enable the timer2 and set timer2 interval to 1000 when the page is finished loading?
You already know how to enable timers. The webbrowser has a DocumentCompleted event where you can subscribe to. This will help you to determine when loading of the page has finished:
private void timer1_Tick(object sender, EventArgs e)
{
webBrowser1.Navigate("website.com/mygambling.php");
webBrowser1.DocumentCompleted += DocumentCompleted;
}
private void DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.DocumentCompleted -= DocumentCompleted;
timer2.Enabled = true;
}

How Do I Use DisplayLabel.Text In Visual C#?

I'm trying to make certain text appear in the label when a button is clicked, but I always get the error `The name DisplayLabel does not exist in the current context. This is my Code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Chapter_2_HW
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void sinisterButton_Click(object sender, EventArgs e)
{
MessageBox.Show("Left");
}
private void mediumButton_Click(object sender, EventArgs e)
{
}
private void dexterButton_Click(object sender, EventArgs e)
{
}
private void instructionLabel_Click(object sender, EventArgs e)
{
}
private void translateLabel_Click(object sender, EventArgs e)
{
DisplayLabel.Text = "Goodbye";
}
}
}

Categories

Resources