So, after a long time I installed Visual Studio to make a program. Something I couldn't find on the internet. What I want to do is, I want to run this program in the background and when I press a key combination, my Button starts to enable. Program works but I have no idea how I can make it run in the background. I searched on the internet and tried few things and it didn't work well.
This is my code:
This is my code:
C#:
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 InternetTry
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control == true && e.KeyCode == Keys.F1)
{
button1.PerformClick();
}
if (e.Control == true && e.KeyCode == Keys.F2)
{
button2.PerformClick();
}
}
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("ipconfig", "/renew"); //For enabling internet
}
private void button2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("ipconfig", "/release"); //For disabling internet
}
}
}