Esempio n. 1
0
 void startEmulation()
 {
     using (Process process = Process.GetCurrentProcess())
         using (ProcessModule module = process.MainModule)
         {
             MouseHookInfo.hHook = MouseHookAPI.SetWindowsHookEx(
                 MouseHookInfo.WH_MOUSE_LL,
                 mouse_proc = new MouseHookAPI.HookProcedureDelegate(MouseHookProc),
                 MouseHookAPI.GetModuleHandle(module.ModuleName), 0);
         }
     if (MouseHookInfo.hHook == IntPtr.Zero)
     {
         MessageBox.Show("SetWindowsHookEx Failed.");
     }
 }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            // グローバルフック
            using (Process process = Process.GetCurrentProcess())
                using (ProcessModule module = process.MainModule)
                {
                    // フックプロシージャを登録
                    MouseHookInfo.hHook = MouseHookAPI.SetWindowsHookEx(
                        MouseHookInfo.WH_MOUSE_LL,
                        mouse_proc = new MouseHookAPI.HookProcedureDelegate(MouseHookProc),
                        MouseHookAPI.GetModuleHandle(module.ModuleName),
                        0);
                }
            if (MouseHookInfo.hHook == IntPtr.Zero)
            {
                MessageBox.Show("SetWindowsHookEx Failed.");
            }

            // EvidenceAppliを最前面に持ってくるための処理(最前面にしっぱなしにはしない)
            this.TopMost = true;
            this.Activate();
            this.TopMost = false;
        }