/// <summary> /// Form Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PDFViewerForm_Load(object sender, EventArgs e) { KeyPreview = true; if (Clipboard.ContainsImage()) { Clipboard.Clear(); } handle = this.Handle; timerPrtScreen.Enabled = true; timerPrtScreen.Interval = 500; //Instal Hook _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(this.KeyPress); //DirectoryDelete Temp DeleteDirectorySelect(false); if (!pdfFileName.Equals(string.Empty)) { FormInitial(pdfFileName); } }
private void button1_Click(object sender, EventArgs e) { //安装勾子 _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(this.KeyPress); }
public DotaSkillScreenshot() { InitializeComponent(); this.Font = new Font("Microsoft YaHei UI", 9, FontStyle.Regular); if (_keyboardHook == null) { _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(this.OnKeyPress); } CheckDotaStatusTimer.Start(); }
/// <summary> /// Form Activated /// </summary> private void PDFViewerForm_Activated(object sender, EventArgs e) { //timerPrtScreen.Stop(); ////Instal Hook if (_keyboardHook != null) { _keyboardHook.UninstallHook(); } _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(this.KeyPress); formActive = true; altKeyActive = false; }
/// <summary> /// Form Deactivate /// </summary> private void PDFViewerForm_Deactivate(object sender, EventArgs e) { ////Cancel Hook if (_keyboardHook != null) { _keyboardHook.UninstallHook(); } //timerPrtScreen.Start(); formActive = false; altKeyActive = false; _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(this.KeyPress); }
public CaptureMouse(MouseEvent mouseEvent) { InitializeComponent(); Top = 0; Left = HalfScreenWidth; MouseEventSingle = mouseEvent; InitPointer(); StuckPointer(); Thread th = new Thread(new ThreadStart(GetMouse)); th.IsBackground = true; th.Start(); FocusHelperButton.Focusable = true; FocusHelperButton.Focus(); //安装勾子 _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(OnKeyPress); CaptureMouse(); }
public Form1() { InitializeComponent(); timer2.Interval = 50; timer2.Start(); timer3.Interval = 50; timer3.Start(); timer4.Interval = 50; timer4.Start(); this.TopMost = true; //软件位置初始化 #region 安装钩子 //安装勾子 _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(this.KeyPress); #endregion }
private void InitialKeyBoardHook() { //安装勾子 _keyboardHook = new KeyboardHookLib(); _keyboardHook.InstallHook(this.KeyPress); }
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(); }
public DeviceHook() { KeyboardHook = new KeyboardHookLib(); MouseHook = new MouseHook(); }