Posted by Connor on Sat 22 Aug 22:43 (modification of post by view diff)
report abuse | View followups from Sneak, EagleWingProd, Jacob and Anonymous | download | new post
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- //InteropServices is what allows us to use DllImport
- namespace ExampleBot
- {
- public partial class Form1 : Form
- {
- //FindWindow
- [DllImport("user32.dll", SetLastError = true)]
- static extern IntPtr FindWindow(
- string lpClassName,
- string lpWindowName);
- //hWnd to make it easier
- IntPtr hWnd = FindWindow(
- null,
- "MapleStory");
- //PostMessage
- [return: MarshalAs(UnmanagedType.Bool)]
- [DllImport("user32.dll", SetLastError = true)]
- static extern bool PostMessage(
- IntPtr hWnd,
- uint Msg,
- int wParam,
- int lParam);
- //Define WM_KEYDOWN
- const int WM_KEYDOWN = 0x100;
- public Form1()
- {
- InitializeComponent();
- }
- private void chksendkey_CheckedChanged(object sender, EventArgs e)
- {
- tmrsendkey.Enabled ^= true;
- // ^= is xor. This means that if it's false, it will become true. If it's true, it will become false. (Opposite)
- }
- private void txtdelay_TextChanged(object sender, EventArgs e)
- {
- tmrsendkey.Interval = Convert.ToInt32(txtdelay.Text);
- //You must convert to an int because txtdelay.Text is a string and it won't convert itself :3
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- FindWindow(null, "MapleStory");
- /* null would be where the Window Class would be.
- * Which is MapleStoryClass for MS. But apparently the class
- * when the 'play screen' is up isnt' MapleStoryClass,
- * and I like opening my stuff at the play screen.
- * So I just used the Window Name instead.
- */
- }
- private void tmrsendkey_Tick(object sender, EventArgs e)
- {
- PostMessage(hWnd, WM_KEYDOWN, 0x41, 0x1e0001);
- //0x41 is wParam and 0x1e0001 is lParam
- //You can find a list of these at http://pastebin.com/f6c1db818
- }
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.