-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
68 lines (61 loc) · 2.2 KB
/
Form1.cs
File metadata and controls
68 lines (61 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Globalization;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public static string Igor = "Minecraft 1.12.2";
public static string Me = "RLCraft";
public Form1()
{
InitializeComponent();
}
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
private void button1_Click(object sender, EventArgs e)
{
InputLanguage myDefaultLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("en-US"));
InputLanguage.CurrentInputLanguage = myDefaultLanguage;
Thread.Sleep(100);
// Get a handle to the Calculator application. The window class
// and window name were obtained using the Spy++ tool.
IntPtr Minecraft = FindWindow(null, Igor);
// Verify that Calculator is a running process.
if (Minecraft == IntPtr.Zero)
{
MessageBox.Show("Minecraft is not running.");
return;
}
// Make Calculator the foreground application and send it
// a set of calculations.
SetForegroundWindow(Minecraft);
SendKeys.SendWait("{ESC}");
Thread.Sleep(300);
SendKeys.SendWait("t");
Thread.Sleep(100);
SendKeys.SendWait("/gamemode 1");
Thread.Sleep(100);
SendKeys.SendWait("{ENTER}");
Thread.Sleep(200);
SendKeys.SendWait("t");
Thread.Sleep(100);
SendKeys.SendWait("/gamemode 0");
Thread.Sleep(100);
SendKeys.SendWait("{ENTER}");
this.Close();
}
}
}