Advertisement
Guest User

Untitled

a guest
May 28th, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 23.03 KB | None | 0 0
  1. using CheckpointTeleporter.Properties;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Runtime.InteropServices;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. using System.Globalization;
  12.  
  13. namespace CheckpointTeleporter
  14. {
  15.     public class Main : Form
  16.     {
  17.         public static int   NONE = 0,
  18.                             MOD_ALT = 1,
  19.                             MOD_CONTROL = 2,
  20.                             MOD_SHIFT = 4,
  21.                             MOD_WIN = 8,
  22.                             WM_HOTKEY = 786;
  23.                            
  24.         private List<Main.coords> list = new List<Main.coords>();
  25.         private IContainer components = (IContainer)null;
  26.        
  27.         private const uint MOUSEEVENTF_LEFTDOWN = 2U;
  28.         private const uint MOUSEEVENTF_LEFTUP = 4U;
  29.        
  30.         // Tools
  31.         private NumericUpDown vehicleYNumeric;
  32.         private TextBox keyText;
  33.         private StatusStrip bottomBar;
  34.         private ToolStripStatusLabel copyrightLabel;
  35.         private Label vehicleLabel;
  36.         private Label keyText;
  37.         private Label cordsLabel;
  38.         private TextBox customKeyText;
  39.         private TextBox zText;
  40.         private TextBox yText;
  41.         private TextBox zText;
  42.         private Label savedCoordsText;
  43.         private Button addButton;
  44.         private ListView cordsView;
  45.         private ColumnHeader cordsViewKey;
  46.         private ColumnHeader cordsViewName;
  47.         private ColumnHeader cordsViewX;
  48.         private ColumnHeader cordsViewY;
  49.         private ColumnHeader cordsViewZ;
  50.         private TextBox nameText;
  51.         private Label infoLabel;
  52.         private Label vehicleInfoText;
  53.  
  54.         public Main()
  55.         {
  56.             this.InitializeComponent();
  57.         }
  58.  
  59.         [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
  60.         public static extern IntPtr GetModuleHandle(string lpModuleName);
  61.  
  62.         [DllImport("user32.dll")]
  63.         private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
  64.  
  65.         [DllImport("user32.dll")]
  66.         private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
  67.  
  68.         [DllImport("user32.dll")]
  69.         private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, IntPtr dwExtraInfo);
  70.  
  71.         [DllImport("kernel32.dll")]
  72.         private static extern IntPtr OpenProcess(Main.ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
  73.  
  74.         [DllImport("kernel32.dll", SetLastError = true)]
  75.         private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);
  76.  
  77.         [DllImport("kernel32.dll", SetLastError = true)]
  78.         private static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, out int lpNumberOfBytesRead);
  79.  
  80.         [DllImport("kernel32.dll")]
  81.         public static extern int CloseHandle(IntPtr hProcess);
  82.  
  83.         public IntPtr getHandleByName()
  84.         {
  85.             Process[] processesByName = Process.GetProcessesByName("gta_sa");
  86.             if(processesByName.Length == 0) {
  87.                 return IntPtr.Zero;
  88.             }
  89.             Process[] processArray = processesByName;
  90.             int index = 0;
  91.             if(index < processArray.Length) {
  92.                 return processArray[index].MainWindowHandle;
  93.             }
  94.             return IntPtr.Zero;
  95.         }
  96.  
  97.         private void WriteInt(int address, int value)
  98.         {
  99.             int bytesWritten;
  100.             Main.WriteMemory(Enumerable.FirstOrDefault<Process>((IEnumerable<Process>)Process.GetProcessesByName("gta_sa")), address, (long)value, out bytesWritten);
  101.         }
  102.  
  103.         private void WriteFloat(int address, float value)
  104.         {
  105.             int bytesWritten;
  106.             Main.WriteMemory2(Enumerable.FirstOrDefault<Process>((IEnumerable<Process>)Process.GetProcessesByName("gta_sa")), address, value, out bytesWritten);
  107.         }
  108.  
  109.         public static bool WriteMemory(Process process, int address, long value, out int bytesWritten)
  110.         {
  111.             IntPtr hProcess = Main.OpenProcess(Main.ProcessAccessFlags.All, false, process.Id);
  112.             byte[] bytes = BitConverter.GetBytes(value);
  113.             bool flag = Main.WriteProcessMemory(hProcess, new IntPtr(address), bytes, (uint)bytes.LongLength, out bytesWritten);
  114.             Main.CloseHandle(hProcess);
  115.             return flag;
  116.         }
  117.  
  118.         public static bool WriteMemory2(Process process, int address, float value, out int bytesWritten)
  119.         {
  120.             IntPtr hProcess = Main.OpenProcess(Main.ProcessAccessFlags.All, false, process.Id);
  121.             byte[] bytes = BitConverter.GetBytes(value);
  122.             bool flag = Main.WriteProcessMemory(hProcess, new IntPtr(address), bytes, (uint)bytes.LongLength, out bytesWritten);
  123.             Main.CloseHandle(hProcess);
  124.             return flag;
  125.         }
  126.  
  127.         public static byte[] ReadMemory(Process process, int address, int numOfBytes)
  128.         {
  129.             IntPtr hProcess = Main.OpenProcess(Main.ProcessAccessFlags.All, false, process.Id);
  130.             byte[] lpBuffer = new byte[numOfBytes];
  131.             int lpNumberOfBytesRead = 0;
  132.             Main.ReadProcessMemory(hProcess, new IntPtr(address), lpBuffer, numOfBytes, out lpNumberOfBytesRead);
  133.             return lpBuffer;
  134.         }
  135.  
  136.         private int ReadInt(int Adresa)
  137.         {
  138.             return BitConverter.ToInt32(Main.ReadMemory(Enumerable.FirstOrDefault<Process>((IEnumerable<Process>)Process.GetProcessesByName("gta_sa")), Adresa, 4), 0);
  139.         }
  140.  
  141.         private float ReadFloat(int Adresa)
  142.         {
  143.             return BitConverter.ToSingle(Main.ReadMemory(Enumerable.FirstOrDefault<Process>((IEnumerable<Process>)Process.GetProcessesByName("gta_sa")), Adresa, 8), 0);
  144.         }
  145.  
  146.         private double ReadDouble(int Adresa)
  147.         {
  148.             return (double)BitConverter.ToSingle(Main.ReadMemory(Enumerable.FirstOrDefault<Process>((IEnumerable<Process>)Process.GetProcessesByName("gta_sa")), Adresa, 8), 0);
  149.         }
  150.  
  151.         private string ReadText(int Adresa)
  152.         {
  153.             return Encoding.Default.GetString(Main.ReadMemory(Enumerable.FirstOrDefault<Process>((IEnumerable<Process>)Process.GetProcessesByName("gta_sa")), Adresa, 8));
  154.         }
  155.  
  156.         private void WUT()
  157.         {
  158.             try
  159.             {
  160.                 Process process = Enumerable.FirstOrDefault<Process>((IEnumerable<Process>)Process.GetProcessesByName("gta_sa"));
  161.                 float markerX = this.ReadFloat(process.MainModule.BaseAddress.ToInt32() + 8904392);
  162.                 float markerY = this.ReadFloat(process.MainModule.BaseAddress.ToInt32() + 8904400);
  163.                 float markerZ = this.ReadFloat(process.MainModule.BaseAddress.ToInt32() + 8904396);
  164.                
  165.                 int num1 = this.ReadInt(11990512);
  166.                 int num2 = this.ReadInt(num1 + 20);
  167.                 int num3 = this.ReadInt(this.ReadInt(num1 + 1420) + 20);
  168.                
  169.                 this.WriteFloat(num3 + 48, markerX);
  170.                 this.WriteFloat(num3 + 52, markerZ);
  171.                 this.WriteFloat(num3 + 56, markerY + (float)(int)this.vehicleYNumeric.Value);
  172.                
  173.                 this.WriteFloat(num2 + 48, markerX);
  174.                 this.WriteFloat(num2 + 52, markerZ);
  175.                 this.WriteFloat(num2 + 56, markerY);
  176.             }
  177.             catch (Exception ex)
  178.             {
  179.             }
  180.         }
  181.  
  182.         private void WUT_XYZ()
  183.         {
  184.             try
  185.             {
  186.                 float X = (float)float.Parse(zText.Text, CultureInfo.InvariantCulture.NumberFormat);
  187.                 float Y = (float)float.Parse(yText.Text, CultureInfo.InvariantCulture.NumberFormat) - 190;
  188.                 float Z = (float)float.Parse(zText.Text, CultureInfo.InvariantCulture.NumberFormat);
  189.  
  190.                 int num1 = this.ReadInt(11990512);
  191.                 int num2 = this.ReadInt(num1 + 20);
  192.                 int num3 = this.ReadInt(this.ReadInt(num1 + 1420) + 20);
  193.  
  194.                 this.WriteFloat(num3 + 48, X);
  195.                 this.WriteFloat(num3 + 52, Z);
  196.                 this.WriteFloat(num3 + 56, Y + (float)(int)this.vehicleYNumeric.Value);
  197.  
  198.                 this.WriteFloat(num2 + 48, X);
  199.                 this.WriteFloat(num2 + 52, Z);
  200.                 this.WriteFloat(num2 + 56, Y);
  201.             }
  202.             catch (Exception ex)
  203.             {
  204.             }
  205.         }
  206.  
  207.         protected override void WndProc(ref Message m)
  208.         {
  209.             if(m.Msg == Main.WM_HOTKEY && m.WParam.ToInt32() == 3) {
  210.                 this.WUT();
  211.             }
  212.            
  213.             if(m.Msg == Main.WM_HOTKEY && m.WParam.ToInt32() == 5) {
  214.                 this.WUT_XYZ();
  215.             }
  216.             base.WndProc(ref m);
  217.         }
  218.  
  219.         protected override void Dispose(bool disposing)
  220.         {
  221.             if(disposing && this.components != null) {
  222.                 this.components.Dispose();
  223.             }
  224.             base.Dispose(disposing);
  225.         }
  226.  
  227.         private void InitializeComponent()
  228.         {
  229.             this.vehicleYNumeric = new System.Windows.Forms.NumericUpDown();
  230.             this.keyText = new System.Windows.Forms.TextBox();
  231.             this.bottomBar = new System.Windows.Forms.StatusStrip();
  232.             this.copyrightLabel = new System.Windows.Forms.ToolStripStatusLabel();
  233.             this.vehicleLabel = new System.Windows.Forms.Label();
  234.             this.keyText = new System.Windows.Forms.Label();
  235.             this.cordsLabel = new System.Windows.Forms.Label();
  236.             this.customKeyText = new System.Windows.Forms.TextBox();
  237.             this.zText = new System.Windows.Forms.TextBox();
  238.             this.yText = new System.Windows.Forms.TextBox();
  239.             this.zText = new System.Windows.Forms.TextBox();
  240.             this.savedCoordsText = new System.Windows.Forms.Label();
  241.             this.addButton = new System.Windows.Forms.Button();
  242.             this.cordsView = new System.Windows.Forms.ListView();
  243.             this.cordsViewKey = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  244.             this.cordsViewName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  245.             this.cordsViewX = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  246.             this.cordsViewY = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  247.             this.cordsViewZ = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  248.             this.nameText = new System.Windows.Forms.TextBox();
  249.             this.infoLabel = new System.Windows.Forms.Label();
  250.             this.vehicleInfoText = new System.Windows.Forms.Label();
  251.             ((System.ComponentModel.ISupportInitialize)(this.vehicleYNumeric)).BeginInit();
  252.             this.bottomBar.SuspendLayout();
  253.             this.SuspendLayout();
  254.             //
  255.             // vehicleYNumeric
  256.             //
  257.             this.vehicleYNumeric.Location = new System.Drawing.Point(19, 80);
  258.             this.vehicleYNumeric.Name = "vehicleYNumeric";
  259.             this.vehicleYNumeric.Size = new System.Drawing.Size(120, 20);
  260.             this.vehicleYNumeric.TabIndex = 0;
  261.             //
  262.             // keyText
  263.             //
  264.             this.keyText.Location = new System.Drawing.Point(19, 41);
  265.             this.keyText.Name = "keyText";
  266.             this.keyText.ReadOnly = true;
  267.             this.keyText.Size = new System.Drawing.Size(100, 20);
  268.             this.keyText.TabIndex = 1;
  269.             this.keyText.Text = "F11";
  270.             this.keyText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.keyText_KeyDown);
  271.             //
  272.             // bottomBar
  273.             //
  274.             this.bottomBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  275.             this.copyrightLabel});
  276.             this.bottomBar.Location = new System.Drawing.Point(0, 228);
  277.             this.bottomBar.Name = "bottomBar";
  278.             this.bottomBar.Size = new System.Drawing.Size(511, 22);
  279.             this.bottomBar.SizingGrip = false;
  280.             this.bottomBar.TabIndex = 2;
  281.             this.bottomBar.Text = "bottomBar";
  282.             //
  283.             // copyrightLabel
  284.             //
  285.             this.copyrightLabel.Name = "copyrightLabel";
  286.             this.copyrightLabel.Size = new System.Drawing.Size(124, 17);
  287.             this.copyrightLabel.Text = "Entwickelt von Caglar.";
  288.             //
  289.             // vehicleLabel
  290.             //
  291.             this.vehicleLabel.AutoSize = true;
  292.             this.vehicleLabel.Location = new System.Drawing.Point(16, 64);
  293.             this.vehicleLabel.Name = "vehicleLabel";
  294.             this.vehicleLabel.Size = new System.Drawing.Size(115, 13);
  295.             this.vehicleLabel.TabIndex = 4;
  296.             this.vehicleLabel.Text = "Fahrzeug Y Koordinate";
  297.             //
  298.             // keyText
  299.             //
  300.             this.keyText.AutoSize = true;
  301.             this.keyText.Location = new System.Drawing.Point(16, 25);
  302.             this.keyText.Name = "keyText";
  303.             this.keyText.Size = new System.Drawing.Size(97, 13);
  304.             this.keyText.TabIndex = 5;
  305.             this.keyText.Text = "Teleportationstaste";
  306.             //
  307.             // cordsLabel
  308.             //
  309.             this.cordsLabel.AutoSize = true;
  310.             this.cordsLabel.Location = new System.Drawing.Point(225, 25);
  311.             this.cordsLabel.Name = "cordsLabel";
  312.             this.cordsLabel.Size = new System.Drawing.Size(115, 13);
  313.             this.cordsLabel.TabIndex = 6;
  314.             this.cordsLabel.Text = "Benutzerdefinierte Orte";
  315.             //
  316.             // customKeyText
  317.             //
  318.             this.customKeyText.Location = new System.Drawing.Point(228, 41);
  319.             this.customKeyText.Name = "customKeyText";
  320.             this.customKeyText.ReadOnly = true;
  321.             this.customKeyText.Size = new System.Drawing.Size(100, 20);
  322.             this.customKeyText.TabIndex = 7;
  323.             this.customKeyText.Text = "F10";
  324.             this.customKeyText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.customKeyText_KeyDown);
  325.             //
  326.             // zText
  327.             //
  328.             this.zText.Location = new System.Drawing.Point(228, 67);
  329.             this.zText.Name = "zText";
  330.             this.zText.Size = new System.Drawing.Size(77, 20);
  331.             this.zText.TabIndex = 8;
  332.             this.zText.Text = "-2704.1953";
  333.             //
  334.             // yText
  335.             //
  336.             this.yText.Location = new System.Drawing.Point(311, 67);
  337.             this.yText.Name = "yText";
  338.             this.yText.Size = new System.Drawing.Size(77, 20);
  339.             this.yText.TabIndex = 9;
  340.             this.yText.Text = "195.3329";
  341.             //
  342.             // zText
  343.             //
  344.             this.zText.Location = new System.Drawing.Point(394, 67);
  345.             this.zText.Name = "zText";
  346.             this.zText.Size = new System.Drawing.Size(77, 20);
  347.             this.zText.TabIndex = 10;
  348.             this.zText.Text = "3.8849";
  349.             //
  350.             // savedCoordsText
  351.             //
  352.             this.savedCoordsText.AutoSize = true;
  353.             this.savedCoordsText.Location = new System.Drawing.Point(225, 106);
  354.             this.savedCoordsText.Name = "savedCoordsText";
  355.             this.savedCoordsText.Size = new System.Drawing.Size(130, 13);
  356.             this.savedCoordsText.TabIndex = 15;
  357.             this.savedCoordsText.Text = "Gespeicherte Koordinaten";
  358.             //
  359.             // addButton
  360.             //
  361.             this.addButton.Enabled = false;
  362.             this.addButton.Location = new System.Drawing.Point(477, 67);
  363.             this.addButton.Name = "addButton";
  364.             this.addButton.Size = new System.Drawing.Size(19, 20);
  365.             this.addButton.TabIndex = 16;
  366.             this.addButton.Text = "+";
  367.             this.addButton.UseVisualStyleBackColor = true;
  368.             this.addButton.Click += new System.EventHandler(this.addButton_Click);
  369.             //
  370.             // cordsView
  371.             //
  372.             this.cordsView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  373.             this.cordsViewKey,
  374.             this.cordsViewName,
  375.             this.cordsViewX,
  376.             this.cordsViewY,
  377.             this.cordsViewZ});
  378.             this.cordsView.Location = new System.Drawing.Point(228, 122);
  379.             this.cordsView.Name = "cordsView";
  380.             this.cordsView.Size = new System.Drawing.Size(268, 92);
  381.             this.cordsView.TabIndex = 17;
  382.             this.cordsView.UseCompatibleStateImageBehavior = false;
  383.             this.cordsView.View = System.Windows.Forms.View.Details;
  384.             //
  385.             // cordsViewKey
  386.             //
  387.             this.cordsViewKey.Text = "#";
  388.             this.cordsViewKey.Width = 33;
  389.             //
  390.             // cordsViewName
  391.             //
  392.             this.cordsViewName.Text = "Name";
  393.             this.cordsViewName.Width = 80;
  394.             //
  395.             // cordsViewX
  396.             //
  397.             this.cordsViewX.Text = "X";
  398.             this.cordsViewX.Width = 52;
  399.             //
  400.             // cordsViewY
  401.             //
  402.             this.cordsViewY.Text = "Y";
  403.             this.cordsViewY.Width = 48;
  404.             //
  405.             // cordsViewZ
  406.             //
  407.             this.cordsViewZ.Text = "Z";
  408.             this.cordsViewZ.Width = 51;
  409.             //
  410.             // nameText
  411.             //
  412.             this.nameText.Location = new System.Drawing.Point(334, 41);
  413.             this.nameText.Name = "nameText";
  414.             this.nameText.Size = new System.Drawing.Size(137, 20);
  415.             this.nameText.TabIndex = 18;
  416.             this.nameText.Text = "Name";
  417.             this.nameText.Click += new System.EventHandler(this.nameText_Click);
  418.             //
  419.             // infoLabel
  420.             //
  421.             this.infoLabel.AutoSize = true;
  422.             this.infoLabel.Location = new System.Drawing.Point(16, 149);
  423.             this.infoLabel.Name = "infoLabel";
  424.             this.infoLabel.Size = new System.Drawing.Size(199, 65);
  425.             this.infoLabel.TabIndex = 19;
  426.             this.infoLabel.Text = "Moment an kann man keine Koordinaten\r\nspeichern. Es ist nur möglich die\r\nX, Y, Z " +
  427.     "Koordinaten anzugeben und die\r\nTaste für das selbst definierte Ort eine\r\nTaste a" +
  428.     "uszusuchen.";
  429.             //
  430.             // vehicleInfoText
  431.             //
  432.             this.vehicleInfoText.AutoSize = true;
  433.             this.vehicleInfoText.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
  434.             this.vehicleInfoText.Location = new System.Drawing.Point(16, 103);
  435.             this.vehicleInfoText.Name = "vehicleInfoText";
  436.             this.vehicleInfoText.Size = new System.Drawing.Size(158, 39);
  437.             this.vehicleInfoText.TabIndex = 20;
  438.             this.vehicleInfoText.Text = "Damit das Fahrzeug nicht zu tief\r\nteleportiert wird, kann man\r\ndie Y Koordinate e" +
  439.     "rhöhen.";
  440.             //
  441.             // Main
  442.             //
  443.             this.ClientSize = new System.Drawing.Size(511, 250);
  444.             this.Controls.Add(this.vehicleInfoText);
  445.             this.Controls.Add(this.infoLabel);
  446.             this.Controls.Add(this.nameText);
  447.             this.Controls.Add(this.cordsView);
  448.             this.Controls.Add(this.addButton);
  449.             this.Controls.Add(this.savedCoordsText);
  450.             this.Controls.Add(this.zText);
  451.             this.Controls.Add(this.yText);
  452.             this.Controls.Add(this.zText);
  453.             this.Controls.Add(this.customKeyText);
  454.             this.Controls.Add(this.cordsLabel);
  455.             this.Controls.Add(this.keyText);
  456.             this.Controls.Add(this.vehicleLabel);
  457.             this.Controls.Add(this.bottomBar);
  458.             this.Controls.Add(this.keyText);
  459.             this.Controls.Add(this.vehicleYNumeric);
  460.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
  461.             this.MaximizeBox = false;
  462.             this.Name = "Main";
  463.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  464.             this.Text = "SA:MP Checkpoint-Teleporter";
  465.             this.Load += new System.EventHandler(this.Main_Load);
  466.             ((System.ComponentModel.ISupportInitialize)(this.vehicleYNumeric)).EndInit();
  467.             this.bottomBar.ResumeLayout(false);
  468.             this.bottomBar.PerformLayout();
  469.             this.ResumeLayout(false);
  470.             this.PerformLayout();
  471.  
  472.         }
  473.  
  474.         [Flags]
  475.         public enum ProcessAccessFlags : uint
  476.         {
  477.             All = 2035711U,
  478.             Terminate = 1U,
  479.             CreateThread = 2U,
  480.             VMOperation = 8U,
  481.             VMRead = 16U,
  482.             VMWrite = 32U,
  483.             DupHandle = 64U,
  484.             SetInformation = 512U,
  485.             QueryInformation = 1024U,
  486.             Synchronize = 1048576U,
  487.         }
  488.  
  489.         private class coords
  490.         {
  491.             public float x;
  492.             public float y;
  493.             public float z;
  494.  
  495.             public coords(double xx, double yy, double zz)
  496.             {
  497.                 this.x = (float)xx;
  498.                 this.y = (float)yy;
  499.                 this.z = (float)zz;
  500.             }
  501.         }
  502.  
  503.         private void keyText_KeyDown(object sender, KeyEventArgs e)
  504.         {
  505.             try
  506.             {
  507.                 Main.UnregisterHotKey(this.Handle, 3);
  508.                 this.keyText.Text = e.KeyCode.ToString();
  509.                 Main.RegisterHotKey(this.Handle, 3, Main.NONE, (int)e.KeyCode);
  510.             }
  511.             catch (Exception ex)
  512.             {
  513.             }
  514.         }
  515.  
  516.         private void Main_Load(object sender, EventArgs e)
  517.         {
  518.             try
  519.             {
  520.                 int currentPos = this.ReadInt(this.ReadInt(11990512) + 20);
  521.                 double currentX = (double)this.ReadFloat(currentPos + 48);
  522.                 double currentY = (double)this.ReadFloat(currentPos + 52);
  523.                 double currentZ = (double)this.ReadFloat(currentPos + 56);
  524.                 Main.RegisterHotKey(this.Handle, 3, Main.NONE, 122);
  525.                 Main.RegisterHotKey(this.Handle, 5, Main.NONE, (int) Keys.F10);
  526.                 if(Settings.Default.loaded) {
  527.                     return;
  528.                 }
  529.                 Settings.Default.loaded = true;
  530.                 Settings.Default.Save();
  531.             }
  532.             catch (Exception ex)
  533.             {
  534.             }
  535.         }
  536.  
  537.         private void customKeyText_KeyDown(object sender, KeyEventArgs e)
  538.         {
  539.             try
  540.             {
  541.                 Main.UnregisterHotKey(this.Handle, 5);
  542.                 this.customKeyText.Text = e.KeyCode.ToString();
  543.                 Main.RegisterHotKey(this.Handle, 5, Main.NONE, (int)e.KeyCode);
  544.             }
  545.             catch (Exception ex)
  546.             {
  547.             }
  548.         }
  549.  
  550.         private void addButton_Click(object sender, EventArgs e)
  551.         {
  552.             string[] item = { nameText.Text, zText.Text, yText.Text, zText.Text };
  553.             cordsView.Items.Add(customKeyText.Text).SubItems.AddRange(item);
  554.         }
  555.  
  556.         private void nameText_Click(object sender, EventArgs e)
  557.         {
  558.             if(nameText.Text == "Name")
  559.             {
  560.                 nameText.Text = "";
  561.             }
  562.         }
  563.     }
  564. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement