public int cpuhelper = 0;
public const string gamename = "oyun";
public struct RECT
{
public int left, top, right, bottom;
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.BackColor = System.Drawing.Color.Wheat;
this.TransparencyKey = System.Drawing.Color.Wheat;
int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
var oyunh = Process.GetProcessesByName("oyun").FirstOrDefault();
if (oyunh != null)
{
var owner = oyunh.MainWindowHandle;
var owned = this.Handle;
var i = SetWindowLong(owned, -8 , owner);
}
reducer.CheckedChanged += reducervoid;
Gui.CheckForIllegalCrossThreadCalls = false;
showcgui();
this.SetStyle(
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer,
true);
Task t = Task.Factory.StartNew(() =>
{
allinone();
});
}
void reducervoid(object sender, EventArgs e)
{
if (reducer.Checked == true)
{
cpuhelper = 1;
}
else if (reducer.Checked == false)
{
cpuhelper = 0;
}
}
private async void allinone()
{
while (true)
{
await Task.Delay(cpuhelper);
Process[] procs = Process.GetProcessesByName("oyun");
if (procs.Length == 0)
{
Environment.Exit(0);
}
else
{
foreach (Process proc in procs)
{
RECT outrect;
GetWindowRect(handle, out outrect);
this.Top = outrect.top;
this.Left = outrect.left;
}
}
}
}