Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Diagnostics;
- namespace MapleLegends_Overlay
- {
- public partial class Form1 : Form
- {
- [DllImport("user32.dll")]
- static extern IntPtr SetParent(IntPtr hwc, IntPtr hwp);
- // Define the FindWindow API function.
- [DllImport("user32.dll", EntryPoint = "FindWindow",
- SetLastError = true)]
- static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly,
- string lpWindowName);
- // Define the SetWindowPos API function.
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- static extern bool SetWindowPos(IntPtr hWnd,
- IntPtr hWndInsertAfter, int X, int Y, int cx, int cy,
- SetWindowPosFlags uFlags);
- // Define the SetWindowPosFlags enumeration.
- [Flags()]
- private enum SetWindowPosFlags : uint
- {
- SynchronousWindowPosition = 0x4000,
- DeferErase = 0x2000,
- DrawFrame = 0x0020,
- FrameChanged = 0x0020,
- HideWindow = 0x0080,
- DoNotActivate = 0x0010,
- DoNotCopyBits = 0x0100,
- IgnoreMove = 0x0002,
- DoNotChangeOwnerZOrder = 0x0200,
- DoNotRedraw = 0x0008,
- DoNotReposition = 0x0200,
- DoNotSendChangingEvent = 0x0400,
- IgnoreResize = 0x0001,
- IgnoreZOrder = 0x0004,
- ShowWindow = 0x0040,
- }
- [DllImport("user32.dll", SetLastError = true)]
- static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
- Overlay frm = new Overlay();
- public Form1()
- {
- InitializeComponent();
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if(checkBox1.Checked == true)
- {
- frm.Show();
- }
- else
- {
- frm.Hide();
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //Process p = Process.Start("c:/MapleLegendsHD/MapleLegends.exe");
- int pidint = Convert.ToInt32(PID.Text);
- Process p = Process.GetProcessById(pidint);
- Thread.Sleep(1000);
- p.WaitForInputIdle();
- SetParent(p.MainWindowHandle, GamePanel.Handle);
- SetFullScreen(true);
- // Find (the first-in-Z-order) Notepad window.
- }
- private void Form1_Layout(object sender, LayoutEventArgs e)
- {
- button1.BringToFront();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if(this.WindowState == FormWindowState.Maximized)
- {
- GamePanel.Size = new Size(this.Width, this.Height);
- }
- else
- {
- GamePanel.Size = new Size(728, 246);
- }
- if(MouseInfo.Checked == true)
- {
- MouseInfoLabel.Visible = true;
- Point p = GamePanel.PointToClient(Cursor.Position);
- //MouseInfoLabel.Location = p;
- MouseInfoLabel.Text = p.ToString();
- }
- else
- {
- MouseInfoLabel.Visible = false;
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void FullScreen_Click(object sender, EventArgs e)
- {
- if (FullScreen.Text == "X")
- SetFullScreen(false);
- else
- SetFullScreen(true);
- }
- private bool SetFullScreen(bool ans)
- {
- if(ans == true)
- {
- this.FormBorderStyle = FormBorderStyle.None;
- this.TopMost = true;
- this.WindowState = FormWindowState.Maximized;
- FullScreen.Text = "X";
- FullScreen.ForeColor = Color.Red;
- ControlPanel.Visible = false;
- }
- else
- {
- this.FormBorderStyle = FormBorderStyle.Sizable;
- this.TopMost = false;
- this.WindowState = FormWindowState.Normal;
- FullScreen.Text = "+";
- FullScreen.ForeColor = Color.Green;
- ControlPanel.Visible = true;
- }
- return false;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- /*int pidint = Convert.ToInt32(PID2.Text);
- Process p = Process.GetProcessById(pidint);
- Thread.Sleep(1000);
- p.WaitForInputIdle();
- SetParent(p.MainWindowHandle, Game2Panel.Handle);*/
- }
- private void MouseInfo_CheckedChanged(object sender, EventArgs e)
- {
- Bitmap bitmap = Screenshot(GamePanel);
- bitmap.Save("test.bmp");
- Process.Start("test.bmp");
- }
- private static Bitmap Screenshot(Control control)
- {
- Bitmap bmpScreenshot = new Bitmap(control.Width, control.Height);
- Graphics g = Graphics.FromImage(bmpScreenshot);
- Rectangle r = control.RectangleToScreen(control.ClientRectangle);
- Point p = new Point(212, 760);
- Size s = new Size(350, 45);
- g.CopyFromScreen(r.Location, Point.Empty, control.Size);
- return bmpScreenshot;
- }
- /*private void button3_Click(object sender, EventArgs e)
- {
- IntPtr hWnd = this.Handle;
- UInt32 pidint = Convert.ToUInt32(PID2.Text, 16);
- uint processid = pidint;
- uint threadid = GetWindowThreadProcessId((IntPtr)hWnd, out processid);
- if (hWnd == IntPtr.Zero)
- {
- MessageBox.Show("Could not find this process.");
- return;
- }
- // Set the window's position.
- int width = int.Parse(txtWidth.Text);
- int height = int.Parse(txtHeight.Text);
- int x = int.Parse(txtX.Text);
- int y = int.Parse(txtY.Text);
- SetWindowPos(hWnd, IntPtr.Zero, x, y, width, height, 0);
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement