資源簡介
可設置毫秒,可用于網絡游戲隨機強化裝備等
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Runtime.InteropServices;
using?System.Diagnostics;
namespace?WindowsFormsApplication1
{
????public?partial?class?Form1?:?Form
????{
????????[System.Runtime.InteropServices.DllImport(“user32“)]
????????private?static?extern?int?mouse_event(int?dwFlags?int?dx?int?dy?int?cButtons?int?dwExtraInfo);
????????const?int?MOUSEEVENTF_LEFTDOWN?=?0x0002;
????????const?int?MOUSEEVENTF_LEFTUP?=?0x0004;
????????[DllImport(“user32.dll“)]
????????public?static?extern?int?SetWindowsHookEx(int?idHook?HookProc?hProc?IntPtr?hMod?int?dwThreadId);
????????[DllImport(“user32.dll“)]
????????public?static?extern?int?CallNextHookEx(int?hHook?int?nCode?IntPtr?wParam?IntPtr?lParam);
????????[DllImport(“user32.dll“)]
????????public?static?extern?bool?UnhookWindowsHookEx(int?hHook);
????????[DllImport(“kernel32.dll“)]//獲取模塊句柄??
????????public?static?extern?IntPtr?GetModuleHandle(string?lpModuleName);
????????public?struct?KeyInfoStruct
????????{
????????????public?int?vkCode;????????//按鍵鍵碼
????????????public?int?scanCode;
????????????public?int?flags;???????//鍵盤是否按下的標志
????????????public?int?time;
????????????public?int?dwExtraInfo;
????????}
????????private?const?int?WH_KEYBOARD_LL?=?13;??????//鉤子類型?全局鉤子
????????private?const?int?WM_KEYUP?=?0x101;?????//按鍵抬起
????????private?const?int?WM_KEYDOWN?=?0x100;???????//按鍵按下
????????public?delegate?int?HookProc(int?nCode?IntPtr?wParam?IntPtr?lParam);
????????bool?bStopMsg?=?false;
????????int?hHook?=?0;
????????GCHandle?gc;
????????string?b?=?“F1“;
????????public?int?MethodHookProc(int?nCode?IntPtr?wParam?IntPtr?lParam)
????????{
????????????if?(nCode?>=?0)
????????????{
????????????????KeyInfoStruct?inputInfo?=?(KeyInfoStruct)Marshal.PtrToStructure(lParam?typeof(KeyInfoStruct));
????????????????if?(wParam?==?(IntPtr)WM_KEYDOWN)
????????????????{//如果按鍵按下
????????????????????//??MessageBox.Show(((Keys)inputInfo.vkCode).ToString());
????????????????????if?(((Keys)inputInfo.vkCode).ToString()?==?b)
????????????????????????if?(timer1.Enabled?==?true)
????????????????????????{
????????????????????????????timer1.Enabled?=?false;
????????????????????????????this.label3.Text?=?“[已停止]“;
????????????????????????}
????????????????????????else
????????????????????????{
????????????????????????????timer1.Enabled?=?true;
????????????????????????????this.label3.Text?=?“[已啟動]“;
????????????????????????}
????????????????}
????????????????if?(bStopMsg)?return?1;
????????????}
????????????return?CallNextHookEx(hHook?nCode?wParam?lParam);//繼續傳遞消息
????????}
????????public?Form1()
????????{
????????????InitializeComponent();
????????????this.comboBox1.SelectedIndex?=?0;//默認索引值
????????????this.comboBox1.DropDownstyle?=?ComboBoxstyle.DropDownList;//僅在列表中選擇
????????????th
- 上一篇:語音 有新訂單請及時處理
- 下一篇:最后一公里EC配送程序源代碼
評論
共有 條評論