Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [DllImport("user32.dll", SetLastError = true)]
- static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
- [StructLayout(LayoutKind.Sequential)]
- private struct RECT
- {
- public int Left;
- public int Top;
- public int Right;
- public int Bottom;
- }
- private static Bitmap ScreenGrab(int x, int y, int width, int height)
- {
- IntPtr hwnd = System.Diagnostics.Process.GetProcessesByName("MapleStory")[0].MainWindowHandle;
- RECT rectRAW = new RECT();
- GetWindowRect(hwnd, ref rectRAW);
- Rectangle rect = new Rectangle(rectRAW.Left, rectRAW.Top, rectRAW.Right - rectRAW.Left, rectRAW.Bottom - rectRAW.Top);
- rect = new Rectangle(rect.X + x, rect.Y + y, width, height);
- // Get information about the screen
- using (Graphics browserGraphics = Graphics.FromHwnd(hwnd))
- // apply that info to a bitmap...
- using (Bitmap screenshot = new Bitmap(rect.Width, rect.Height, browserGraphics))
- // and create an Graphics to manipulate that bitmap.
- using (Graphics imageGraphics = Graphics.FromImage(screenshot))
- {
- imageGraphics.CopyFromScreen(rect.X, rect.Y, 0, 0, new Size(rect.Width, rect.Height));
- return (Bitmap)screenshot.Clone();
- }
- }
- ----------------------------
- case "level":
- int level = int.Parse(splitted[1]);
- Send(new UpdatePlayerStatMessage()
- {
- ItemReaction = false,
- Stats =
- {
- { PlayerStats.Level, level },
- { PlayerStats.Exp, 0 },
- }
- });
- System.Threading.Thread.Sleep(1500);
- try
- {
- string filename = "C:/ExpTable.png";
- if (!File.Exists(filename))
- {
- using (Bitmap bmp = new Bitmap(168 + 68, 34 * 50, PixelFormat.Format32bppArgb))
- {
- bmp.Save(filename, ImageFormat.Png);
- }
- }
- using (Bitmap lvlBmp = ScreenGrab(7, 591, 68, 34))
- using (Bitmap expBmp = ScreenGrab(399, 591, 168, 34))
- using (Bitmap savedBmp = (Bitmap)Bitmap.FromStream(new MemoryStream(File.ReadAllBytes(filename))))
- using (Graphics graphics = Graphics.FromImage(savedBmp))
- {
- graphics.DrawImage(lvlBmp, 0, (level - 200) * 34);
- graphics.DrawImage(expBmp, lvlBmp.Width, (level - 200) * 34);
- savedBmp.Save(filename, ImageFormat.Png);
- }
- Console.WriteLine("saved " + level);
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement