コード例 #1
0
        /// <summary>
        /// 鼠标点击事件
        /// </summary>
        void Hook_OnMouseActivity(object sender, MouseEventArgs e)
        {
            SelectedHwnd = FindWindowInfo.GetWindowHWND(e.X, e.Y);
            string gameName = FindWindowInfo.GetWindowName(SelectedHwnd);
            int    pid      = FindWindowInfo.GetProcessIDByHWND(SelectedHwnd);

            if (Process.GetCurrentProcess().Id != pid)
            {
                ProcessInfoLabel.Text = "[实时]" + gameName + "—" + pid;
            }
            hook.Stop();
            WindowChooseBtn.BtnText = "选择窗口";
        }
コード例 #2
0
 private void SelectGameWindowBtn_BtnClick(object sender, EventArgs e)
 {
     if (SelectGameWindowBtn.BtnText == "选择窗口")
     {
         bool r = hook.Start();
         if (r)
         {
             SelectGameWindowBtn.BtnText = "结束选择";
             //MessageBox.Show("安装钩子成功!");
         }
         else
         {
             MessageBox.Show("安装钩子失败!");
         }
     }
     else if (SelectGameWindowBtn.BtnText == "结束选择")
     {
         hook.Stop();
         SelectGameWindowBtn.BtnText = "选择窗口";
     }
 }
コード例 #3
0
        /// <summary>
        /// 翻译窗口关闭事件
        /// Hook:关闭进程
        /// OCR:关闭鼠标钩子
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GameTranslateForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            Common.TransMode = 0;
            if (Common.TextractorHandle != null)
            {
                Common.TextractorHandle.SetGameTransForm(null);
                Common.TextractorHandle.CloseTextractor();
            }

            if (hook != null)
            {
                hook.Stop();
                hook = null;
            }
        }