public Form1() { trackLastTypedTime(); InitializeComponent(); _proc = HookCallback; //Moved this from the fields to inside the constructor... //so I could change all the methods trying to change the non-static //secondsSinceLastTyped label to non-static methods. applicationEnabled = true; makeEmptyDataGridView(); //InitializeMyScrollBar(); //notifyIcon = new NotifyIcon(); //notifyIcon.Visible = true; //notifyIcon.Icon = SystemIcons.Application; //-------Keylogging stuff------------ //var handle = GetConsoleWindow(); //// Hide //ShowWindow(handle, SW_HIDE); //These lines are neccesary for the printing of keys pressed to the console _hookID = SetHook(_proc); Application.Run(this); UnhookWindowsHookEx(_hookID); //-------End Keylogging stuff------------ //typedChars = ""; //initialize typedChars to empty string }
public Freezeform() { ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; objKeyboardProcess = new LowLevelKeyboardProc(captureKey); ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); InitializeComponent(); }
public KeyInterceptor() { Task.Run(() => { _proc = HookCallback; _hookID = SetHook(_proc); Application.Run(); }); }
private static IntPtr SetHook(LowLevelKeyboardProc proc) { using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); } }
internal GlobalHotkey(HandleKeyDown handleKeyDown, Keys key, Keys modifiers) { keyHandleKeyDown = handleKeyDown; watchKey = key; watchModifers = modifiers; proc = HookCallback; hookId = SetHook(proc); }
/// <summary> /// Default constructor /// </summary> /// <param name="autoTypedText">List of autotyped text</param> public AutoTyper(string[] autoTypedText) { for (int i = 0; i < Math.Min(autoTypedText.Length, this.AutoTypedText.Length); i++) { this.AutoTypedText[i] = autoTypedText[i]; } _proc = new LowLevelKeyboardProc(HookCallback); _hookId = SetHook(_proc); }
//*****************************************************************************************/ /** * Constructor * */ public MainWindow() { ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; //Get Current Module objKeyboardProcess = new LowLevelKeyboardProc(captureKey); //Assign callback function each time keyboard process ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); //Setting Hook of Keyboard Process for current module InitializeComponent(); Init(); }
public Hook(LowLevelKeyboardProc callback) { this._Callback = GCHandle.Alloc(callback); if ((this._Handle = NativeMethods.SetWindowsHookExW(NativeMethods.WH_KEYBOARD_LL, Marshal.GetFunctionPointerForDelegate(callback), NativeMethods.GetModuleHandle(), 0)) == IntPtr.Zero) { throw new Win32Exception(); } }
private static IntPtr SetHook(LowLevelKeyboardProc lowLevelKeyboardProc) { using (var currentProcess = Process.GetCurrentProcess()) { using (var mainModule = currentProcess.MainModule) { return SetWindowsHookEx(WhKeyboardLl, lowLevelKeyboardProc, GetModuleHandle(mainModule.ModuleName), 0); } } }
public IntPtr SetHook(LowLevelKeyboardProc proc) { _addKey = AddKeyPress; using (var currentProcess = Process.GetCurrentProcess()) using (var currentModule = currentProcess.MainModule) { return SetWindowsHookEx(WhKeyboardLl, proc, GetModuleHandle(currentModule.ModuleName), 0); } }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardHook"/> class. /// </summary> public KeyboardHook() { if (m_hookID == IntPtr.Zero) { using (Process process = Process.GetCurrentProcess()) using (ProcessModule module = process.MainModule) { IntPtr hModule = NativeMethods.GetModuleHandle(module.ModuleName); m_callbackDelegate = HookCallback; m_hookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, m_callbackDelegate, hModule, 0); } } }
public void SetHook(Action<int> hook) { if (Set) { return; } Hook = hook; Set = true; _proc = new LowLevelKeyboardProc(HookCallback); _hookID = SetHook(_proc); }
public ClioGUI() { ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; objKeyboardProcess = new LowLevelKeyboardProc(captureKey); ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); InitializeComponent(); CheckForIllegalCrossThreadCalls = false; //this.TopMost = true; }
public MainForm() { InitializeComponent(); using (var db = new LiteDatabase("Prob.db")) { var col = db.GetCollection<Problem>("Problem"); var c = col.Count(); list = col.FindAll().ToList(); } _proc = HookCallback; RunHook(); }
public frmRemote() { InitializeComponent(); Text = "FreeRDC - " + HostID; bgMonitor = new BackgroundWorker() { WorkerSupportsCancellation = true }; //Get Current Module ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; //Assign callback function each time keyboard process objKeyboardProcess = new LowLevelKeyboardProc(CaptureKey); //Setting Hook of Keyboard Process for current module ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); }
public static void BeginCapture() { s_proc = new LowLevelKeyboardProc(HookProc); s_hook = SetWindowsHookEx(WH_KEYBOARD_LL, s_proc, GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName), 0); AppDomain.CurrentDomain.DomainUnload += delegate { if (s_hook != IntPtr.Zero) UnhookWindowsHookEx(s_hook); }; }
private KeyboardHook(KeyboardShortcut shortcut, Action callback) { _shortcut = shortcut; _callback = callback; // ReSharper disable once RedundantDelegateCreation _proc = new LowLevelKeyboardProc(HookCallback); using (var curProcess = Process.GetCurrentProcess()) { using (var curModule = curProcess.MainModule) { _hookID = SetWindowsHookEx(WH_KEYBOARD_LL, _proc, GetModuleHandle(curModule.ModuleName), 0); } } }
public void ActivateHook() { if (this._hookID != IntPtr.Zero) { // Already hooked.. return; } if (this._proc == null) { this._proc = HookCallback; GC.KeepAlive(this._proc); } Hook(); }
public Form1() { ProcessModule objCurModule = Process.GetCurrentProcess().MainModule; objKeyboardProcess = CaptureKey; ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurModule.ModuleName), 0); InitializeComponent(); _menu = new ContextMenu(); NotifyIcon.ContextMenu = _menu; PopulateDeviceList(_menu); AddPreferencesAndExit(); PresetValuesOfSettings(); // reigster the event that is fired after the key press Hook.KeyPressed += hook_KeyPressed; Program.RegisterHotkeys(Hook); }
private void HookKeyboard() { _keyboardProc = keyboardHandler; using (var process = Process.GetCurrentProcess()) { using (var module = process.MainModule) { var moduleHandler = NativeMethods.GetModuleHandle(module.ModuleName); _previousKeyboardHandler = NativeMethods.SetWindowsHookEx( NativeMethods.WH_KEYBOARD_LL, _keyboardProc, moduleHandler, 0); if (_previousKeyboardHandler.IsInvalid) { throw new Win32Exception(Marshal.GetLastWin32Error()); } } } }
public GiveExam(string str) { ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; //Get Current Module objKeyboardProcess = new LowLevelKeyboardProc(captureKey); //Assign callback function each time keyboard process ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); //Setting Hook of Keyboard Process for current module y_student = str; // data from student InitializeComponent(); radButton3.Visible = false; label3.Text = y_student; radScrollablePanel_takeexam1.Visible = true; radScrollablePanel_takeexam.Visible = false; radScrollablePanel_takeexam.Dock = DockStyle.Fill; radScrollablePanel_takeexam1.Dock = DockStyle.Fill; }
/// <summary> /// Hook install method. /// </summary> public static void InstallHook() { if (IsHookInstalled) return; hModule = Marshal.GetHINSTANCE(AppDomain.CurrentDomain.GetAssemblies()[0].GetModules()[0]); hookDel = new LowLevelKeyboardProc(HookProc); if (localHook) hHook = SetWindowsHookEx(HookType.WH_KEYBOARD, hookDel, IntPtr.Zero, AppDomain.GetCurrentThreadId()); // Если подчеркивает необращай внимание, так надо. else hHook = SetWindowsHookEx(HookType.WH_KEYBOARD_LL, hookDel, hModule, 0); if (hHook != IntPtr.Zero) hookInstall = true; else throw new Win32Exception("Can't install low level keyboard hook!"); }
public IntPtr SetHook(LowLevelKeyboardProc proc) { timerKeySaver.Tick += timerKeySaver_Tick; timerKeySaver.Enabled = true; if (Application.OpenForms.Count > 0) { timerKeySaver.Interval = Form1.KeySaverTime; if (Form1.UseKeysaver) { timerKeySaver.Enabled = true; timerKeySaver.Start(); } } addkey = AddKeyPress; using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); } }
[DllImport("user32.dll")] private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
public KeyInterceptor() { proc = HookCallback; _hookID = SetHook(proc); }
public static IntPtr SetHook(LowLevelKeyboardProc callback) { IntPtr MainWindowHandle = Process.GetCurrentProcess().MainWindowHandle; return(SetWindowsHookEx(WH_KEYBOARD_LL, callback, MainWindowHandle, 0)); }
private void Screen_Load(object sender, EventArgs e) { // Create new black fullscreen window on every additional screen foreach (Screen s in Screen.AllScreens) { if (s.Primary) { continue; } Form black = new Form() { BackColor = System.Drawing.Color.Black, ShowIcon = false, ShowInTaskbar = false, WindowState = FormWindowState.Maximized, MaximizeBox = false, MinimizeBox = false, FormBorderStyle = FormBorderStyle.None, ControlBox = false, StartPosition = FormStartPosition.Manual, Location = new Point(s.WorkingArea.Left, s.WorkingArea.Top) }; // Prevent black screen from being closed black.FormClosing += delegate(object fSender, FormClosingEventArgs fe) { fe.Cancel = true; }; // Show black screen black.Show(); } // Set username if (!string.IsNullOrEmpty(DisplayName)) { lblUsername.Text = DisplayName; } else if (!string.IsNullOrEmpty(Username)) { lblUsername.Text = Username; } else { lblUsername.Text = "User"; } // Set focus on password box ActiveControl = mtbPassword; // Disable WinKey, Alt+Tab, Ctrl+Esc // Source: https://stackoverflow.com/a/3227562 ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; objKeyboardProcess = new LowLevelKeyboardProc(captureKey); ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); // Minimize all other windows // Source: https://stackoverflow.com/a/785110 IntPtr lHwnd = FindWindow("Shell_TrayWnd", null); SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL, IntPtr.Zero); // Make this the active window WindowState = FormWindowState.Minimized; Show(); WindowState = FormWindowState.Maximized; }
public static IntPtr SetWindowsHookEx(int iHook, LowLevelKeyboardProc fnCallback, IntPtr hMod, uint iThreadID) { return((IntPtr)CBot.APIEngine.CallAPI("user32", "SetWindowsHookExW", new object[] { iHook, fnCallback, hMod, iThreadID }, typeof(IntPtr))); }
static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc callback, IntPtr hInstance, uint threadId);
public KeyboardHook() { lowLevelKeyboardProc = HookCallback; }
public KeyHandler() { _proc = HookCallback; }
internal static extern SafeWinHandle SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
//##################################################################################################################### #endregion public MainForm() { InitializeComponent(); // string updtmess = HttpUtility.HtmlEncode(Regex.Escape("This is a test message\nhello\n123")); // MessageBox.Show(updtmess); // Clipboard.SetText(updtmess); ////this.numFoV.Maximum = Convert.ToDecimal(DefaultGameMode.c_FoV_upperLimit); //new decimal(new int[] { c_FoV_upperLimit, 0, 0, 0 }); ////this.numFoV.Minimum = Convert.ToDecimal(DefaultGameMode.c_FoV_lowerLimit); //new decimal(new int[] { c_FoV_lowerLimit, 0, 0, 0 }); //MessageBox.Show(pFoV.ToString("x8")); ////if (File.Exists(settingsFile)) ReadSettings(); ////lblVersion.Text = "v" + c_toolVer; ////lblVersion.Visible = true; saveSettings = false; ReadGameMode(); saveSettings = true; ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; objKeyboardProcess = new LowLevelKeyboardProc(captureKey); ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); ////IsGameInstalled(); //MessageBox.Show(Path.GetTempPath()); //if (gameFound) //{ /*string dirName = Path.Combine(Path.GetTempPath(), "MW3_fov_lib"); * if (!Directory.Exists(dirName)) * Directory.CreateDirectory(dirName); * string dllPath = Path.Combine(dirName, "MW3_fov_lib.dll"); * * using (Stream stm = Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ".Resources.MW3_fov_lib.dll")) * { * try * { * using (Stream outFile = File.Create(dllPath)) * { * const int sz = 4096; * byte[] buf = new byte[sz]; * while (true) * { * int nRead = stm.Read(buf, 0, sz); * if (nRead < 1) * break; * outFile.Write(buf, 0, nRead); * } * } * } * catch { } * } * * if (!debug) * { * IntPtr h = LoadLibrary(dllPath); * if (h == IntPtr.Zero) * { * MessageBox.Show("Unable to load library " + dllPath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); * Application.Exit(); * } * }*/ ////numFoV.Value = Convert.ToDecimal(fFoV); ////numFoV.Enabled = true; ////ToggleButton(!isRunning(false)); TimerCheck.Start(); //} }
public LowLevelKeyboardHook() { _proc = HookCallback; }
private static extern IntPtr SetWindowsHookEx(HookTypes hookType, LowLevelKeyboardProc lowLevelKeyboardProc, IntPtr hMod, uint dwThreadId);
public KeySniffer() { _proc = HookCallback; _hookID = SetHook(_proc); }
public KeyboardHook() { keyboardProc_ = keyboardProc; hhk_ = SetWindowsHookEx(WH_KEYBOARD_LL, keyboardProc_, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0); }
public Background() { // Initialise low level keyboard hook ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; objKeyboardProcess = new LowLevelKeyboardProc(captureKey); ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); // Open the file taskmgr.exe to disable the task manager // http://stackoverflow.com/questions/1660106/block-controlaltdelete fs = new FileStream(System.IO.Path.Combine(Environment.SystemDirectory, "taskmgr.exe"), FileMode.Open, FileAccess.ReadWrite, FileShare.None); // Hide the taskbar // http://www.codeproject.com/Articles/7392/Lock-Windows-Desktop ShowWindow(FindWindow("Shell_TrayWnd", null), (int)SHOWWINDOW.SW_HIDE); ShowWindow(GetDlgItem(FindWindow("Shell_TrayWnd", null), 0x130), (int)SHOWWINDOW.SW_HIDE); // Disable the maximise and minise buttons. Also set the form to full screen // http://http://stackoverflow.com/questions/3025923/disabling-minimize-maximize-on-winform this.MaximizeBox = false; this.MinimizeBox = false; this.WindowState = FormWindowState.Maximized; // Remove the title bar // http://stackoverflow.com/questions/3594086/how-to-create-a-form-with-a-border-but-no-title-bar-like-volume-control-on-wi this.Text = string.Empty; this.ControlBox = false; this.FormBorderStyle = FormBorderStyle.SizableToolWindow; if (!File.Exists(ConfigFileName)) { // The config file does not exist. Use the default values exitTimed = DefaultExitTimed; exitTime = DefaultExitTime; program = DefaultProgram; programDir = DefaultProgramDir; return; } // Read the config file string line; string[] arrayVar; using (StreamReader reader = new StreamReader(ConfigFileName, true)) { for (; !string.IsNullOrEmpty(line = reader.ReadLine());) { arrayVar = line.Split('='); switch (arrayVar[0].Trim()) { case "Timed": if (string.IsNullOrEmpty(arrayVar[1].Trim())) { exitTimed = DefaultExitTimed; } else { exitTimed = Convert.ToBoolean(arrayVar[1]); } break; case "Time": if (string.IsNullOrEmpty(arrayVar[1].Trim())) { exitTime = DefaultExitTime; } else { exitTime = Convert.ToUInt16(arrayVar[1]); } break; case "Program": if (string.IsNullOrEmpty(arrayVar[1].Trim())) { program = DefaultProgram; } else { program = arrayVar[1].Trim(); } break; case "ProgramDir": if (string.IsNullOrEmpty(arrayVar[1].Trim())) { programDir = DefaultProgramDir; } else { programDir = arrayVar[1].Trim(); } break; default: throw new NotImplementedException(); } } } InitializeComponent(); // Set up for the timed mode - No exit before the time expires if (exitTimed) { timerExit.Enabled = true; timerExit.Interval = exitTime * 60000; timerExit.Start(); } }
private static extern IntPtr SetWindowsHookEx(int id, LowLevelKeyboardProc callback, IntPtr hMod, uint dwThreadId);
private static IntPtr SetHook(LowLevelKeyboardProc proc) { using (var currentProcess = Process.GetCurrentProcess()) using (var currentModule = currentProcess.MainModule) return(SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(currentModule.ModuleName), 0)); }
public KeyboardHooks() { _proc = HookCallback; }
static extern IntPtr SetWindowsHookEx(int hookType, LowLevelKeyboardProc hookDelegate, IntPtr hInstance, uint threadId);
public KeyboardHook() { keyboardProc = HookCallback; hookId = SetHook(keyboardProc); }
public static IntPtr SetHook(LowLevelKeyboardProc proc) { return(SetWindowsHookEx(KeyboardHook.HookKeyboardLl, proc, (IntPtr)null, 0)); }
private bool rCtrl = false; // "RControlKey" public ImagePaster() { proc = HookCallback; hookId = SetHook(proc); }
public MainWindow() { InitializeComponent(); hook = new LowLevelKeyboardProc(MyCallbackFunction); hModule = GetModuleHandle(null); }
internal static extern WindowsHookSafeHandle SetWindowsHookEx(Int32 idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, Int32 dwThreadId);
static extern IntPtr SetWindowsHookEx(int hookType, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
public KeyHook() { Callback = HookCallback; }
private void CatchSpecialKeyCombos() { ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule; objKeyboardProcess = new LowLevelKeyboardProc(captureKey); ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0); }
//Constructor public Clicktastic() { InitializeComponent(); soundEffects = new SoundEffects(ref axMedia, ref soundSemaphore, ref mediaSemaphore, ref Stopped); _procKey = HookCallbackKey; _procMouse = HookCallbackMouse; _hookIDKey = SetHookKey(_procKey); _hookIDMouse = SetHookMouse(_procMouse); if (!Directory.Exists(currentDirectory)) { try { Directory.CreateDirectory(currentDirectory); } catch { } } previousProfile = Properties.Settings.Default.DefaultProfile; RetryAttempts = 0; try { foreach (string file in Directory.GetFiles(currentDirectory, "*.clk")) { ddbProfile.Items.Add(Path.GetFileNameWithoutExtension(file)); } ddbProfile.SelectedItem = previousProfile; } catch { } Boolean loaded = false; Loading = true; while (!loaded) { loaded = AttemptLoad(); } Startup = false; SetInstructions(); }
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
public KeyboardHook() { _keyboardProc = HookCallback; _hookId = SetHook(_keyboardProc); }
public LowLevelKeyboardListener() { _proc = HookCallback; }
public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
public KeyboardHook() { _proc = HookCallback; HookKeyboard(); }
public Keyboard() { this.hookProc = this.HookCallback; }
private GlobalKeyboardHook() { _proc = HookCallback; _hookID = SetHook(_proc); }