91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 0.03M
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2020-12-26
  • 語言: C#
  • 標簽: 鉤子??拼圖??C#??

資源簡介

利用c#寫的jpg拼圖軟件,可以隨意剪切和拼接




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace AutoDrawRect
{
    public class MouseHook
    {
        //好吧這個沒有用到
        private bool isSet;
        public bool IsSet {
            get { return isSet; }
        }
        //這個也沒有用到
        private int handleOfHook;
        public int HandleOfHook {
            get { return handleOfHook; }
        }
        //這個還是沒有用到、、、淡定!
        private bool isStopMsg;
        public bool IsStopMsg {
            get { return isStopMsg; }
            set { isStopMsg = value; }
        }
        //自己定義了一個事件 放到Hook里面去
        public delegate void MEventhandler(object sender, MouseInfoEventArys e);
        public event MEventhandler HooKMouseEvent;

        [DllImport("user32.dll")]//設置鉤子  第二個參數為回調函數指針
        public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, 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 const int WH_MOUSE_LL = 14;//全局鼠標Hook 7是局部的 13全局鍵盤 2局部鍵盤
        public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam);//話說c#里面委托就是函數指針?、

        private const int WM_LBUTTONDOWN = 0x201;   //在Hook里面判斷是否左鍵點下
        private const int WM_RBUTTONUP = 0x205;     //在Hook里面判斷是否右鍵抬起

        public struct POINT {//鼠標位置的結構體
            public int x;
            public int y;
        }
        public struct MouseLLInfo {//全局鼠標Hook的結構體
            public POINT pt;    //其實這里可以用Point只是這個新建的類里面沒有應用System.Windows.Forms(應該是這個)
            public int mouseData;
            public int flags;
            public int time;
            public int dwExtraInfo;
        }

        GCHandle gc;//好吧 話說就是應為這個東西害得我研究了兩天 沒有這個的話 程序運行一會兒就提示崩潰了
        //因為垃圾回收期把我的回調函數當垃圾收了 所以運行程序的時候 一會兒就提示我 一個垃圾的回調導致程序崩潰
        //在非托管調用托管的時候 必須保持托管代碼的或活動性 大概就這個意思 反正就是被收廢品的收了、害的我用.net3.5用其他方式設置Hook

        public int MouseHookProcedure(int nCode, IntPtr wParam, IntPtr lParam) {//這個就是回調函數了
            if (nCode >= 0 && HooKMouseEvent != null) {//先判斷是否事件被綁定(感覺有點多余的判斷 丫的我不在上面綁定 我寫Hook干嘛)
                //話說是把內存的什么什么轉換成結構體
                MouseLLInfo mouseInfo = (MouseLLInfo)Marshal.PtrToStructure(lParam, typeof(MouseLLInfo));
                Btn btn = Btn.None;         //自己定義的一個枚舉 里面只有三個值
                if (wParam == (IntPtr)WM_LBUTTONDOWN) {         //如果左鍵被點下
                    btn = Btn.LeftDowm;
                } else if (wParam == (IntPtr)WM_RBUTTONUP) {    //如果右鍵被抬起
                    btn = Btn.RightUp;
                }
                //好吧 我就不知道當時我怎么想的 在Hook里面獲取的坐標 有負數的現象 所以在那邊 我沒用這個坐標
                MouseInfoEventArys e = new MouseInfoEventArys(btn, mouseInfo.pt.x, mouseInfo.pt.y);
                HooKMouseEvent(this, e);//觸發綁定到這個上面的事件
            }
            return CallNextHookEx(handleOfHook, nCode, wParam, lParam);//繼續下一個鉤子
        }
        
        public bool SetMouseHook() {    //設置Hook
            if (isSet) {//如果已經設置了 就不要設置啦、、、
                return false;
            }
            HookProc MouseCallBack = new HookProc(MouseHookProcedure);
            handleOfHook = SetWindowsHookEx(WH_MOUSE_LL, MouseCallBack, 
                GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName), 0);
            if (handleOfHook != 0) {//如果設置成功、、
                gc = GCHandle.Alloc(MouseCallBack);//這個就是那個什么什么、、然后我的回調就不會被收廢品的揀去了
                isSet = true;
                return true;
            }
            return false;
        }
        public bool UnLoadMouseHook() {
            if (!isSet) {//如果裝都沒有裝那么久不要卸載啦、、
                return false;
            }
            if (UnhookWindowsHookEx(handleOfHook)) {
                gc.Free();//將回調釋放掉、、
                isSet = false;
                return true;
            }
            return false;
        }

    }

    public enum Btn//我只感覺到這三個有用、(應該是兩個 左鍵點下 右鍵抬起)
    {
        LeftDowm, RightUp, None
    }
    public class MouseInfoEventArys {//話說定義事件的時候都是這么寫的 所以我也弄一個內出來保存事件參數
        private int x;//坐標 多余的后來才發現 鼠標慢慢貼近屏幕邊緣的時候 3 2 1 0 -1 、、丫的 負數都出來了
        public int X {
            get { return x; }
        }

        private int y;//坐標
        public int Y {
            get { return y; }
        }

        private Btn mBtn;
        public Btn MBtn {
            get { return mBtn; }//鼠標的情況
        }
        public MouseInfoEventArys(Btn btn,int x,int y) {//構造器
            mBtn = btn;
            this.x = x;
            this.y = y;
        }

    }
}


資源截圖

代碼片段和文件信息

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;
//Download?by?http://www.codefans.net
using?System.Runtime.InteropServices;

namespace?AutoDrawRect
{
????public?partial?class?Form1?:?Form
????{
????????[DllImport(“user32.dll“)]
????????public?static?extern?bool?RegisterHotKey(IntPtr?hWnd?int?id?int?fsModifiers?int?vk);
????????public?const?int?MOD_ALT?=?0x1;
????????public?const?int?MOD_CONTROl?=?0x2;
????????public?const?int?HOTKEY?=?0x312;
????????[DllImport(“user32.dll“)]
????????public?static?extern?bool?UnregisterHotKey(IntPtr?hWnd?int?id);
????????
????????public?Form1()?{
????????????InitializeComponent();
????????}
???

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????4064??2012-04-22?18:00??softhy.net\AutoDrawRect\AutoDrawRect\AutoDrawRect.csproj

?????文件???????1595??2012-06-26?17:53??softhy.net\AutoDrawRect\AutoDrawRect\Form1.cs

?????文件???????2076??2012-04-22?16:53??softhy.net\AutoDrawRect\AutoDrawRect\Form1.Designer.cs

?????文件???????5817??2012-04-22?16:53??softhy.net\AutoDrawRect\AutoDrawRect\Form1.resx

?????文件??????14413??2012-06-26?17:53??softhy.net\AutoDrawRect\AutoDrawRect\Form2.cs

?????文件???????6217??2012-04-22?17:25??softhy.net\AutoDrawRect\AutoDrawRect\Form2.Designer.cs

?????文件??????10634??2012-04-22?17:25??softhy.net\AutoDrawRect\AutoDrawRect\Form2.resx

?????文件???????6277??2012-06-26?17:53??softhy.net\AutoDrawRect\AutoDrawRect\MouseHook.cs

?????文件????????532??2012-06-26?17:56??softhy.net\AutoDrawRect\AutoDrawRect\Program.cs

?????文件???????1454??2012-03-06?19:26??softhy.net\AutoDrawRect\AutoDrawRect\Properties\AssemblyInfo.cs

?????文件???????2769??2012-03-06?19:26??softhy.net\AutoDrawRect\AutoDrawRect\Properties\Resources.Designer.cs

?????文件???????5612??2012-03-06?19:26??softhy.net\AutoDrawRect\AutoDrawRect\Properties\Resources.resx

?????文件???????1075??2012-03-06?19:26??softhy.net\AutoDrawRect\AutoDrawRect\Properties\Settings.Designer.cs

?????文件????????249??2012-03-06?19:26??softhy.net\AutoDrawRect\AutoDrawRect\Properties\Settings.settings

?????文件???????1513??2012-06-26?17:56??softhy.net\AutoDrawRect\AutoDrawRect\WinAPI.cs

?????文件????????878??2012-03-06?19:26??softhy.net\AutoDrawRect\AutoDrawRect.sln

????..A..H.?????25600??2012-04-22?19:41??softhy.net\AutoDrawRect\AutoDrawRect.suo

?????目錄??????????0??2012-06-26?17:50??softhy.net\AutoDrawRect\AutoDrawRect\Properties

?????目錄??????????0??2012-06-26?17:52??softhy.net\AutoDrawRect\AutoDrawRect

?????目錄??????????0??2012-06-26?17:50??softhy.net\AutoDrawRect

?????目錄??????????0??2012-06-26?17:56??softhy.net

-----------?---------??----------?-----??----

????????????????90775????????????????????21


評論

共有 條評論