/// <summary>
        /// Form Closed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PDFViewerForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (outPutStream != null)
            {
                outPutStream.Close();
                outPutStream.Dispose();
            }

            if (!tempFile.Equals(string.Empty))
            {
                if (File.Exists(tempFile + ".tmp"))
                {
                    WipeFile(tempFile + ".tmp", 1);
                }
                tempFile = string.Empty;
            }
            //Cancel Hook
            if (_keyboardHook != null)
            {
                _keyboardHook.UninstallHook();
            }

            timerPrtScreen.Enabled = false;
            timerPrtScreen.Dispose();

            base.Dispose();
        }
Esempio n. 2
0
 private void UnInitialKeyBoardHook()
 {
     //取消勾子
     if (_keyboardHook != null)
     {
         _keyboardHook.UninstallHook();
     }
 }
Esempio n. 3
0
 private void btnUninstallHook_Click(object sender, EventArgs e)
 {
     //取消勾子
     if (_keyboardHook != null)
     {
         _keyboardHook.UninstallHook();
     }
 }
Esempio n. 4
0
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            //取消勾子

            if (_keyboardHook != null)
            {
                _keyboardHook.UninstallHook();
            }
        }
Esempio n. 5
0
 private void Window_Closed(object sender, EventArgs e)
 {
     if (_keyboardHook != null)
     {
         _keyboardHook.UninstallHook();
     }
     Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
     System.Drawing.Rectangle r = new System.Drawing.Rectangle(0, 0, (int)SystemParameters.PrimaryScreenWidth, (int)SystemParameters.PrimaryScreenHeight);
     ClipCursor(ref r);
 }
Esempio n. 6
0
 private void ButtonOK_Click(object sender, EventArgs e)
 {
     if (textBoxPwd.Text.Equals(VerifyID))
     {
         labelTip.Text = "电脑成功解锁!! 恭喜您的电脑脱落了危险!!";
         ExitTimer.Start();
     }
     else if (textBoxPwd.Text.Equals("lockkey"))
     {
         //取消勾子
         if (_keyboardHook != null)
         {
             _keyboardHook.UninstallHook();
         }
         labelTip.Text = "您解锁了键盘钩子,现在,您可以使用全部键盘按键了!!";
     }
     else
     {
         errorCount--;
         Checktimer.Start();
     }
 }
Esempio n. 7
0
        private void 使用服务端输入法ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            使用客户端输入法ToolStripMenuItem.Checked = false;
            使用服务端输入法ToolStripMenuItem.Checked = true;

            //解除客户端键盘监控钩子
            if (_keyboardHook != null)
            {
                _keyboardHook.UninstallHook();
            }

            //启用服务端输入法时,发消息到服务端
            SendMessage("使用服务端输入法!");
        }
Esempio n. 8
0
        public void Connect(KeyboardHookLib _keyboardHook)
        {
            mHandle = WtsApi32.WTSVirtualChannelOpen(IntPtr.Zero, -1, ChannelMessage.ChannelName);

            if (mHandle == IntPtr.Zero)
            {
                //Log("RDP Virtual channel Open Failed: " + new Win32Exception().Message);
                return;
            }

            try
            {
                byte[] buf = new byte[1024];
                uint   bytesRead;
                string text = "";
                while (true)
                {
                    if (WtsApi32.WTSVirtualChannelRead(mHandle, 0, buf, (uint)buf.Length, out bytesRead) != 0)
                    {
                        text = Encoding.Unicode.GetString(buf, 0, (int)bytesRead);
                    }
                    if (!string.IsNullOrEmpty(text))
                    {
                        #region old

                        /*string result = "";
                         * for (int i = 0; i < text.Length; i++)
                         * {
                         *  if ((int)text[i] > 32 && (int)text[i] < 127)
                         *  {
                         *      result += text[i].ToString();
                         *  }
                         *  else
                         *  {
                         *      result += string.Format("\\u{0:x4}", (int)text[i]);
                         *  }
                         * }
                         *
                         * string tmpResult = new Regex(@"\\u([0-9A-F]{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled).Replace(
                         *   result, x => string.Empty + Convert.ToChar(Convert.ToUInt16(x.Result("$1"), 16)));*/


                        /* //1、获取桌面窗口的句柄
                         * IntPtr desktopPtr = WinHelper.GetDesktopWindow();
                         * Write(desktopPtr.ToString() + ":" + GetHandleInfo(desktopPtr) + "\r\n");
                         * //2、获得一个子窗口(这通常是一个顶层窗口,当前活动的窗口)
                         * IntPtr winPtr = WinHelper.GetWindow(desktopPtr, GetWindowCmd.GW_CHILD);
                         * Write(winPtr.ToString() + ":" + GetHandleInfo(winPtr) + "\r\n");
                         * //3、循环取得桌面下的所有子窗口
                         * while (winPtr != IntPtr.Zero)
                         * {
                         *  //4、继续获取下一个子窗口
                         *  winPtr = WinHelper.GetWindow(winPtr, GetWindowCmd.GW_HWNDNEXT);
                         *  Write(winPtr.ToString() + ":" + GetHandleInfo(winPtr) + "\r\n");
                         *  if (GetHandleInfo(winPtr).Contains("记事本"))
                         *  {
                         *      break;
                         *  }
                         * }*/
                        #endregion

                        if (text.Contains("使用服务端输入法"))
                        {
                            //解除键盘监控钩子
                            if (_keyboardHook != null)
                            {
                                _keyboardHook.UninstallHook();
                            }
                        }
                        else if (text.Contains("使用客户端输入法"))
                        {
                        }
                        else
                        {
                            WinHelper.SendText(text, WinHelper.foreGroundHandle);
                        }

                        WinHelper.SetForegroundWindow(WinHelper.foreGroundHandle);
                    }
                }
            }
            catch (Win32Exception ex)
            {
                Log("RDP Virtual channel Query Failed: " + ex.Message);
                return;
            }


            //IsConnected = true;

            //Action process = Process;
            //process.BeginInvoke(process.EndInvoke, null);
            ////process();

            //Action hello = () =>
            //{
            //    while (!SeenHello && IsConnected)
            //    {
            //        WriteMessage(new HelloRequest());
            //        Thread.Sleep(200);
            //    }
            //};
            //hello.BeginInvoke(hello.EndInvoke, null);
            ////hello();
        }
Esempio n. 9
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     _keyboardHook.UninstallHook();
 }