第一次寫教程難免有些小激動,今天我來教大家寫一個壓槍宏咕村,我下面先把關(guān)鍵部分代碼貼上來:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
? ? ? ? private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
? ? ? ? [System.Runtime.InteropServices.DllImport("user32.dll")]
? ? ? ? public static extern int GetAsyncKeyState(int vKey);
? ? ? ? static int st = 0;//下壓幅度
? ? ? ? const int MOUSEEVENTF_MOVE = 0x0001;
我們需要在Timer控件下執(zhí)行此代碼:
private void timer1_Tick(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? label1.Text ="當(dāng)前幅度"+ st.ToString();
? ? ? ? ? ? if (GetAsyncKeyState(1) != 1 && GetAsyncKeyState(1) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? mouse_event(MOUSEEVENTF_MOVE, 0, st, 0, 0);
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(38) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st++;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(40) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st--;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(37) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st = 0;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(39) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? V();
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(97) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st = (int)numericUpDown1.Value;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(98) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st = (int)numericUpDown2.Value;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(99) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st = (int)numericUpDown3.Value;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(100) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st = (int)numericUpDown4.Value;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(101) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st = (int)numericUpDown5.Value;
? ? ? ? ? ? }
? ? ? ? ? ? if (GetAsyncKeyState(102) != 0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? st = (int)numericUpDown6.Value;
? ? ? ? ? ? }
? ? ? ? }
以上就是我們壓槍宏的主體代碼不跟,由于這是第一次寫教程所以不知從何寫起犬性,就吧主體代碼貼上來了泥耀,下面我把程序連接貼上去大家需要的可以下載使用神郊,但此程序僅供學(xué)習(xí)使用迅办,請勿用它做一些它違法違規(guī)的事情宅静!否則后果自負(fù)與本人無關(guān)!U酒邸姨夹!點(diǎn)擊(微型壓槍宏)下載程序如果對你有幫助纤垂,請記得我,我是?貓九先森磷账!? ?程序中有個小彩蛋哦峭沦!快去發(fā)現(xiàn)吧!請給我一個大大的贊以鼓勵我?