/// <summary> /// 键盘鼠标钩子初始化 /// </summary> private void MouseKeyboardHook_Init() { if (Common.UsingHotKey.IsMouse == true) { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.OnMouseActivity += new System.Windows.Forms.MouseEventHandler(Hook_OnMouseActivity); } } else { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.KeyDown += new System.Windows.Forms.KeyEventHandler(Hook_OnKeyBoardActivity); } } bool r = hook.Start(); if (!r) { HandyControl.Controls.Growl.ErrorGlobal(Application.Current.Resources["Hook_Error_Hint"].ToString()); } }
public void StartCapture(INativeWindowManagement nativeWinManagement) { nativeWindowManagement = nativeWinManagement; GlobalHook.AddListener(WindowHookCallback, listenedMessageTypes); GlobalHook.IsActive = true; }
private void WbElementRecorder_DomKeyDown(object sender, DomKeyEventArgs e) { //mouse down has occured if (e != null) { try { if (_isRecording) { LoadSearchParameters(_lastSavedPoint); lblDescription.Text = _recordingMessage; } if (IsRecordingSequence && _isRecording) { BuildElementSetTextActionCommand(e.KeyCode); } else if ((Keys)Enum.ToObject(typeof(Keys), e.KeyCode) == GlobalHook.StopHookKey) { //STOP HOOK GlobalHook.StopHook(); GlobalHook.HookStopped -= GlobalHook_HookStopped; return; } } catch (Exception) { lblDescription.Text = _errorMessage; } } }
/// <summary> /// 键盘鼠标钩子初始化 /// </summary> private void MouseKeyboardHook_Init() { if (Common.UsingHotKey.IsMouse) { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.OnMouseActivity += Hook_OnMouseActivity; } } else { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.KeyDown += Hook_OnKeyBoardActivity; } } bool r = hook.Start(); if (!r) { Growl.ErrorGlobal(Application.Current.Resources["Hook_Error_Hint"].ToString()); } }
/// <summary> /// 键盘鼠标钩子初始化 /// </summary> private void MouseKeyboardHook_Init() { if (Common.UsingHotKey.IsMouse == true) { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.OnMouseActivity += new System.Windows.Forms.MouseEventHandler(Hook_OnMouseActivity); } } else { //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.KeyDown += new System.Windows.Forms.KeyEventHandler(Hook_OnKeyBoardActivity); } } bool r = hook.Start(); if (!r) { HandyControl.Controls.Growl.ErrorGlobal("安装钩子失败"); } }
private void uiBtnRecord_Click(object sender, EventArgs e) { if (uiBtnRecord.DisplayText == "Start") { Height = 120; Width = 500; BringToFront(); MoveFormToBottomRight(this); TopMost = true; pnlOptions.Hide(); lblRecording.Show(); FormBorderStyle = 0; uiBtnRecord.DisplayText = "Stop"; uiBtnRecord.Image = Resources.various_stop_button; uiBtnRecord.Location = new Point(lblRecording.Right + 5, lblRecording.Location.Y); int.TryParse(txtHookResolution.Text, out int samplingResolution); GlobalHook.HookStopped += new EventHandler(OnHookStopped); GlobalHook.StartScreenRecordingHook(chkCaptureClicks.Checked, chkCaptureMouse.Checked, chkGroupMovesIntoSequences.Checked, chkCaptureKeyboard.Checked, chkCaptureWindowEvents.Checked, chkActivateTopLeft.Checked, chkTrackWindowSize.Checked, chkTrackWindowsOpenLocation.Checked, samplingResolution, txtHookStop.Text); lblRecording.Text = "Press '" + txtHookStop.Text + "' key to stop recording!"; // WindowHook.StartHook(); _scriptCommandList = new List <ScriptCommand>(); } else { GlobalHook.StopHook(); } }
private void GlobalHook_KeyDownEvent(object sender, KeyDownEventArgs e) { //key down has occured if (e != null) { //invoke UIA try { if (_isRecording) { LoadSearchParameters(e.MouseCoordinates); lblDescription.Text = _recordingMessage; } if (IsRecordingSequence && _isRecording) { BuildElementSetTextActionCommand(e.Key); } else if (e.Key.ToString() == GlobalHook.StopHookKey) { //STOP HOOK GlobalHook.StopHook(); GlobalHook.HookStopped -= GlobalHook_HookStopped; return; } } catch (Exception) { lblDescription.Text = _errorMessage; } } }
public void Initialize(Dictionary<string, object> appInfo, Dictionary<string, object> entryPointInformation) { try { VmcExecuteAddIn.entryPointInfo = entryPointInformation; object obj1; VmcExecuteAddIn.entryPointInfo.TryGetValue("Title", out obj1); VmcExecuteAddIn.ExecutionTitle = obj1 as string; object obj2; if (!VmcExecuteAddIn.entryPointInfo.TryGetValue("ImageUrl", out obj2)) VmcExecuteAddIn.entryPointInfo.TryGetValue("ThumbnailUrl", out obj2); VmcExecuteAddIn.ExecutionImageUrl = obj2 as string; object obj3; if (!VmcExecuteAddIn.entryPointInfo.TryGetValue("Context", out obj3)) throw new InvalidOperationException("Context not found."); this.executionInfo = (ExecutionInfo)new XmlSerializer(typeof(ExecutionInfo)).Deserialize((TextReader)new StringReader(((string)obj3).Trim())); if (this.executionInfo == null) throw new FormatException("Could not interpret context."); bool flag1 = !string.IsNullOrEmpty(this.executionInfo.FileName); bool flag2 = this.executionInfo.Media != null && this.executionInfo.Media.Count > 0; if (!flag1 && !flag2 && !this.executionInfo.Page.HasValue) throw new InvalidOperationException("No file name, page or media specified."); if (!flag1) return; this.executionInfo.FileName = System.Environment.ExpandEnvironmentVariables(this.executionInfo.FileName); object obj4; if (!this.executionInfo.RequiresDirectX && VmcExecuteAddIn.entryPointInfo.TryGetValue("CapabilitiesRequired", out obj4)) this.executionInfo.RequiresDirectX = ((string)obj4).IndexOf("directx", StringComparison.InvariantCultureIgnoreCase) != -1; VmcExecuteAddIn.globalHook = new GlobalHook(); VmcExecuteAddIn.ExecutionEngine = new ExecutionEngine(this.executionInfo, VmcExecuteAddIn.globalHook); VmcExecuteAddIn.ExecutionEngine.ExecutionFinished += (EventHandler)delegate { Application.DeferredInvoke(new DeferredHandler(this.ExecutionFinishedHandler)); }; VmcExecuteAddIn.ExecutionEngine.ExecutionError += (EventHandler<Advent.VmcExecute.ErrorEventArgs>)((sender, args) => Application.DeferredInvoke(new DeferredHandler(this.ExecutionErrorHandler), (object)args)); if (string.IsNullOrEmpty(VmcExecuteAddIn.ExecutionTitle)) VmcExecuteAddIn.ExecutionTitle = Path.GetFileNameWithoutExtension(this.executionInfo.FileName); VmcExecuteAddIn.messagePump = new Thread((ThreadStart)(() => { try { if (VmcExecuteAddIn.ExecutionEngine.RequiresKeyboardHook) VmcExecuteAddIn.globalHook.Start(false, true); System.Windows.Threading.Dispatcher.Run(); } catch (ThreadAbortException) { } })); VmcExecuteAddIn.messagePump.SetApartmentState(ApartmentState.STA); VmcExecuteAddIn.messagePump.IsBackground = true; VmcExecuteAddIn.messagePump.Start(); } catch (Exception ex) { VmcExecuteAddIn.LogError(ex.ToString()); throw; } }
public void TestGlobalHook_AddListener() { /* PRECONDITIONS */ Debug.Assert(hookNativeMethods != null); Debug.Assert(hookNativeMethods.Mock != null); /* GIVEN */ const int numOfEvent = 50; const int numOfNotEvent = 20; const GlobalHook.MessageType messageType = GlobalHook.MessageType.WM_USER; using var resetCounter = new CountdownEvent(numOfEvent); using var autoReset = new AutoResetEvent(false); GlobalHook.CppGetMessageCallback callback = null; hookNativeMethods.AllowMessageTypeRegistry(messageType); hookNativeMethods.AllowLibraryLoad(); hookNativeMethods.Mock .Setup(hook => hook.SetHook(It.IsAny <GlobalHook.CppGetMessageCallback>(), It.IsAny <bool>()))? .Callback((GlobalHook.CppGetMessageCallback cppCallback, bool isBlocking) => { callback = cppCallback; autoReset.Set(); }); /* WHEN */ GlobalHook.AddListener(message => { Assert.AreEqual((uint)messageType, message.Type); resetCounter.Signal(); }, messageType); GlobalHook.IsActive = true; Assert.IsTrue(autoReset.WaitOne(maxWaitTime)); Assert.IsNotNull(callback); for (var index = 0; index < numOfEvent; index++) { callback(new GlobalHook.HookMessage() { Type = (uint)messageType }); } // We check if our listener still gets called on events we don't care about. If it will this // test will throw because the resetCounter will be set to a negative number. for (var index = 0; index < numOfNotEvent; index++) { callback(new GlobalHook.HookMessage() { Type = (uint)GlobalHook.MessageType.WM_APP }); } /* THEN */ Assert.IsTrue(resetCounter.Wait(maxWaitTime)); }
private void GlobalHook_KeyDownEvent(object sender, KeyDownEventArgs e) { if (e.Key == GlobalHook.StopHookKey) { GlobalHook.KeyDownEvent -= GlobalHook_KeyDownEvent; GlobalHook.StopHook(); } }
public frmScriptEngine() { InitializeComponent(); //set file ScriptEngineContext.FilePath = null; //get engine settings _engineSettings = new ApplicationSettings().GetOrCreateApplicationSettings().EngineSettings; //initialize Logger switch (_engineSettings.LoggingSinkType) { case SinkType.File: if (string.IsNullOrEmpty(_engineSettings.LoggingValue1.Trim())) { _engineSettings.LoggingValue1 = Path.Combine(Folders.GetFolder(FolderType.LogFolder), "OpenBots Engine Logs.txt"); } ScriptEngineContext.EngineLogger = new Logging().CreateFileLogger(_engineSettings.LoggingValue1, Serilog.RollingInterval.Day, _engineSettings.MinLogLevel); break; case SinkType.HTTP: ScriptEngineContext.EngineLogger = new Logging().CreateHTTPLogger("", _engineSettings.LoggingValue1, _engineSettings.MinLogLevel); break; } //determine whether to show listbox or not _advancedDebug = _engineSettings.ShowAdvancedDebugOutput; //if listbox should be shown if (_advancedDebug) { lstSteppingCommands.Show(); lblMainLogo.Show(); pbBotIcon.Hide(); lblAction.Hide(); } else { lstSteppingCommands.Hide(); lblMainLogo.Hide(); pbBotIcon.Show(); lblAction.Show(); } //apply debug window setting if (!_engineSettings.ShowDebugWindow) { Visible = false; Opacity = 0; } //add hooks for hot key cancellation GlobalHook.HookStopped += new EventHandler(OnHookStopped); GlobalHook.StartEngineCancellationHook(_engineSettings.CancellationKey); }
/// <summary> /// 键盘点击事件 /// </summary> void Hook_OnKeyBoardActivity(object sender, System.Windows.Forms.KeyEventArgs e) { HotKey.IsMouse = false; HotKey.KeyCode = e.KeyCode; HotKeyTag.Text = "已设置触发键 键值:" + HotKey.KeyCode; hook.Stop(); hook = null; WaitHotKeyDrawer.IsOpen = false; }
/// <summary> /// Initializes a keyboard hook /// Remember to specify an event <KeyboardMessageEvent cref="KeyboardMessageEvent"/> /// </summary> /// <param name="stealthyHook"></param> public void InitKeyboardHook(bool stealthyHook = false) { StealthyKeyboardHook = stealthyHook; if (KeyboardHook != null) { KeyboardHook.Dispose(); } KeyboardHook = new GlobalHook(HookType.WH_KEYBOARD_LL, KeyboardHookCallback); }
public void Initialize() { Debug.Assert(Mock != null); Mock .SetupGet(mock => mock.HookLibraryName)? .Returns(mockLibraryName); GlobalHook.Initialize(Mock.Object); }
/// <summary> /// 键盘点击事件 /// </summary> void Hook_OnKeyBoardActivity(object sender, System.Windows.Forms.KeyEventArgs e) { HotKey.IsMouse = false; HotKey.KeyCode = e.KeyCode; HotKeyTag.Text = Application.Current.Resources["ChooseHotKeyPage_HotKeyTag"].ToString() + HotKey.KeyCode; hook.Stop(); hook = null; OCRDelayBox.Focus();//设置完后应该转移焦点 WaitHotKeyDrawer.IsOpen = false; }
/// <summary> /// Initializes a mousehook /// Remember to specify an <MouseMessageEvent cref="MouseMessageEvent"/> /// </summary> /// <param name="stealthyHook"></param> public void InitMouseHook(bool stealthyHook = false) { StealthyMouseHook = stealthyHook; if (MouseHook != null) { MouseHook.Dispose(); } MouseHook = new GlobalHook(HookType.WH_MOUSE_LL, MouseHookCallback); }
private static void Main() { using (var globalHook = new GlobalHook()) using (var processMgr = new ProcessManager()) using (var cameraMgr = new CameraManager(globalHook, processMgr)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Main(processMgr, cameraMgr)); } }
/// <inheritdoc /> public override void Dispose() { base.Dispose(); MouseHook.Dispose(); MouseHook = default; GameData = default; GameProcess = default; }
/// <summary> /// Initializes hooks /// </summary> private void SetUpHooks() { if (!(Site != null && Site.DesignMode)) { _mouseHook = new GlobalHook(GlobalHook.HookTypes.Mouse); _mouseHook.MouseWheel += new MouseEventHandler(_mouseHook_MouseWheel); _mouseHook.MouseDown += new MouseEventHandler(_mouseHook_MouseDown); _keyboardHook = new GlobalHook(GlobalHook.HookTypes.Keyboard); _keyboardHook.KeyDown += new KeyEventHandler(_keyboardHook_KeyDown); } }
private void GlobalHook_KeyDownEvent(object sender, KeyDownEventArgs e) { //key down has occured if (e != null) { //invoke UIA try { if (_isRecording && e.Key != GlobalHook.StopHookKey) { var process = GetProcess((int)e.MouseCoordinates.X, (int)e.MouseCoordinates.Y); if (process.ProcessName == "OpenBots.Studio") { return; } var windowName = process.MainWindowTitle; if (WindowName != windowName && !string.IsNullOrEmpty(windowName)) { WindowName = windowName; cboWindowTitle.SelectedItem = WindowName; if (IsRecordingSequence) { BuildActivateWindowCommand(); } } LoadSearchParameters(e.MouseCoordinates); lblDescription.Text = _recordingMessage; } if (IsRecordingSequence && _isRecording && e.Key != GlobalHook.StopHookKey) { BuildElementSetTextActionCommand(e.Key); } else if (e.Key == GlobalHook.StopHookKey) { //STOP HOOK GlobalHook.StopHook(); GlobalHook.HookStopped -= GlobalHook_HookStopped; return; } } catch (Exception) { lblDescription.Text = _errorMessage; } } }
public void TestGlobalHook_IsActiveTrue_NullNativeHook() { /* PRECONDITIONS */ /* GIVEN */ GlobalHook.Initialize(null); /* WHEN */ GlobalHook.IsActive = true; /* THEN */ Assert.IsFalse(GlobalHook.IsActive); }
public ChooseOCRAreaPage() { InitializeComponent(); Common.ocr = OCRCommon.OCRAuto(Common.appSettings.OCRsource); //初始化钩子对象 if (hook == null) { hook = new GlobalHook(); hook.OnMouseActivity += new System.Windows.Forms.MouseEventHandler(Hook_OnMouseActivity); } }
//events and methods #region Form Events/Methods public frmScriptEngine(string pathToFile, frmScriptBuilder builderForm, List <Core.Script.ScriptVariable> variables = null, bool blnCloseWhenDone = false) { InitializeComponent(); if (variables != null) { Variables = variables; } CloseWhenDone = blnCloseWhenDone; //set callback form callBackForm = builderForm; //set file this.filePath = pathToFile; //get engine settings engineSettings = new Core.ApplicationSettings().GetOrCreateApplicationSettings().EngineSettings; //determine whether to show listbox or not advancedDebug = engineSettings.ShowAdvancedDebugOutput; //if listbox should be shown if (advancedDebug) { lstSteppingCommands.Show(); lblMainLogo.Show(); pbBotIcon.Hide(); lblAction.Hide(); } else { lstSteppingCommands.Hide(); lblMainLogo.Hide(); pbBotIcon.Show(); lblAction.Show(); } //apply debug window setting if (!engineSettings.ShowDebugWindow) { this.Visible = false; this.Opacity = 0; } //add hooks for hot key cancellation GlobalHook.HookStopped += new EventHandler(OnHookStopped); GlobalHook.StartEngineCancellationHook(engineSettings.CancellationKey); }
//events and methods #region Form Events/Methods public frmScriptEngine(EngineContext engineContext, bool blnCloseWhenDone = false, bool isDebugMode = false) { InitializeComponent(); ScriptEngineContext = engineContext; engineContext.ScriptEngine = this; IsDebugMode = isDebugMode; CloseWhenDone = blnCloseWhenDone; //get engine settings _engineSettings = new ApplicationSettings().GetOrCreateApplicationSettings().EngineSettings; if (isDebugMode) { _engineSettings.ShowDebugWindow = true; _engineSettings.ShowAdvancedDebugOutput = true; } //determine whether to show listbox or not _advancedDebug = _engineSettings.ShowAdvancedDebugOutput; //if listbox should be shown if (_advancedDebug) { lstSteppingCommands.Show(); lblMainLogo.Show(); pbBotIcon.Hide(); lblAction.Hide(); } else { lstSteppingCommands.Hide(); lblMainLogo.Hide(); pbBotIcon.Show(); lblAction.Show(); } //apply debug window setting if (!_engineSettings.ShowDebugWindow) { Visible = false; Opacity = 0; } //add hooks for hot key cancellation GlobalHook.HookStopped += new EventHandler(OnHookStopped); GlobalHook.StartEngineCancellationHook(_engineSettings.CancellationKey); }
private void frmProcessingStatus_Load(object sender, EventArgs e) { if (engineSettings.ShowDebugWindow) { this.BringToFront(); MoveFormToBottomRight(this); } GlobalHook.HookStopped += new EventHandler(OnHookStopped); GlobalHook.StartEngineCancellationHook(); bgwRunScript.RunWorkerAsync(); }
/// <summary> /// Sets the hook for the clipboard cut event. /// </summary> public void StartCapture(IClipboardWindowMessageSink windowMessageSink, INativeClipboard nativeClip) { clipboardWindowMessageSink = windowMessageSink; nativeClipboard = nativeClip; if (clipboardWindowMessageSink == null) { return; } clipboardWindowMessageSink.ClipboardUpdated += OnClipboardUpdate; GlobalHook.IsActive = true; GlobalHook.AddListener(GlobalHookCallBack, GlobalHook.MessageType.WM_CUT); }
internal ExecutionEngine(ExecutionInfo info, GlobalHook globalHook) { this.execInfo = info; this.hook = globalHook; this.psi = new ProcessStartInfo() { FileName = this.execInfo.FileName, Arguments = this.execInfo.Arguments, UseShellExecute = true }; if (this.psi.FileName == null) { throw new ArgumentException("A file to execute must be provided."); } }
public void TestGlobalHook_AddListener_UnsupportedMessageType() { /* PRECONDITIONS */ Debug.Assert(hookNativeMethods != null); Debug.Assert(hookNativeMethods.Mock != null); /* GIVEN */ const GlobalHook.MessageType messageType = GlobalHook.MessageType.WM_USER; hookNativeMethods.DisallowMessageTypeRegistry(messageType); /* WHEN */ Assert.ThrowsException <NotSupportedException>(() => GlobalHook.AddListener(message => { }, messageType)); /* THEN */ hookNativeMethods.Mock.Verify(hook => hook.SetHook(It.IsAny <GlobalHook.CppGetMessageCallback>(), It.IsAny <bool>()), Times.Never); }
public int Execute(RecordOptions options) { Debug.Assert(consoleFormatter != null, nameof(consoleFormatter) + " != null"); Debug.Assert(sessionManager != null, nameof(sessionManager) + " != null"); Debug.Assert(commandLine != null, nameof(commandLine) + " != null"); Debug.Assert(messageLoop != null, nameof(messageLoop) + " != null"); if (options == null) { return(-1); } try { consoleFormatter.IsVerbose = options.IsVerbose; // Load Configuration File consoleFormatter.PrintDebug(loadedFileMessage); var configPath = new FilePath(Path.GetFullPath(options.ConfigPath)); // Load Session Manager consoleFormatter.PrintDebug(sessionManagerMessage); // Start Recording consoleFormatter.PrintDebug(startRecordingMessage); sessionManager.StartRecording(); // If the user cancels via the command line we need to stop the message loop. commandLine.Launch(messageLoop.Stop); // Run message loop required for Windows hooks messageLoop.Start(); // To prevent the generated video file from becoming corrupted, recording needs to be stopped manually sessionManager.StopRecording(); Console.WriteLine(stopRecordingMessage); GlobalHook.FreeLibrary(); return(0); } catch (Exception exception) // I know this is not a recommend way to deal with exception, however this method receives a arbitrary amount of exception types. { consoleFormatter.PrintError(exception); return(-1); } }
private void pbRecord_Click(object sender, EventArgs e) { // this.WindowState = FormWindowState.Minimized; if (!chkStopOnClick.Checked) { lblDescription.Text = $"Recording. Press F2 to stop recording!"; MoveFormToBottomRight(this); TopMost = true; } else { WindowState = FormWindowState.Minimized; } Size = new Size(540, 156); SearchParameters = new DataTable(); SearchParameters.Columns.Add("Enabled"); SearchParameters.Columns.Add("Parameter Name"); SearchParameters.Columns.Add("Parameter Value"); SearchParameters.TableName = DateTime.Now.ToString("UIASearchParamTable" + DateTime.Now.ToString("MMddyy.hhmmss")); //clear all SearchParameters.Rows.Clear(); //get window name and find window string windowName = cboWindowTitle.Text; IntPtr hWnd = User32Functions.FindWindow(windowName); //check if window is found if (hWnd != IntPtr.Zero) { //set window state and move to 0,0 User32Functions.SetWindowState(hWnd, Enums.WindowState.SwShowNormal); User32Functions.SetForegroundWindow(hWnd); User32Functions.SetWindowPosition(hWnd, 0, 0); //start global hook and wait for left mouse down event GlobalHook.StartEngineCancellationHook(Keys.F2); GlobalHook.HookStopped += GlobalHook_HookStopped; GlobalHook.StartElementCaptureHook(chkStopOnClick.Checked); GlobalHook.MouseEvent += GlobalHook_MouseEvent; } }
public frmScriptEngine() { InitializeComponent(); //set file this.filePath = null; //get engine settings engineSettings = new Core.ApplicationSettings().GetOrCreateApplicationSettings().EngineSettings; //determine whether to show listbox or not advancedDebug = engineSettings.ShowAdvancedDebugOutput; //if listbox should be shown if (advancedDebug) { lstSteppingCommands.Show(); lblMainLogo.Show(); pbBotIcon.Hide(); lblAction.Hide(); } else { lstSteppingCommands.Hide(); lblMainLogo.Hide(); pbBotIcon.Show(); lblAction.Show(); } //apply debug window setting if (!engineSettings.ShowDebugWindow) { this.Visible = false; this.Opacity = 0; } //add hooks for hot key cancellation GlobalHook.HookStopped += new EventHandler(OnHookStopped); GlobalHook.StartEngineCancellationHook(engineSettings.CancellationKey); }
static void Main() { FontInstaller.AddFontResourceA(Directory.GetCurrentDirectory() + "\\MyMMUniversal.ttf"); RegistryKey reg = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"); if (IsAlreadyRunning()) { MessageBox.Show("MyInput is already running.", "MyInput", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); EnumWindows(new EnumWinCallBack(EnumWindowCallBack), 0); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (kh = new GlobalHook()) { Application.Run(new Main()); } }
internal bool KeyEvent(int nCode, IntPtr wParam, GlobalHook.KBDLLHOOKSTRUCT lParam, bool shift, bool gis) { if (active) { log.write("IO-IN: " + lParam.vkCode.ToString()); if (kl != null) { if (nCode == 0x0d) { SystemKeyEvent(); return false; } return iop.Income(lParam.vkCode, gis, shift, kl); } else { return !imp.Income(lParam.vkCode); } return true; } else { return false; } }