Exemple #1
0
        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
        }
 internal GlobalHotkey(HandleKeyDown handleKeyDown, Keys key, Keys modifiers)
 {
     keyHandleKeyDown = handleKeyDown;
     watchKey = key;
     watchModifers = modifiers;
     proc = HookCallback;
     hookId = SetHook(proc);
 }
Exemple #3
0
        public Freezeform()
        {
            ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule;
            objKeyboardProcess = new LowLevelKeyboardProc(captureKey);
            ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0);

            InitializeComponent();
        }
 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);
     }
 }
 public KeyInterceptor()
 {
     Task.Run(() => {
         _proc = HookCallback;
         _hookID = SetHook(_proc);
         Application.Run();
     });
 }
Exemple #6
0
 /// <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);
 }
Exemple #7
0
        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();
            }
        }
Exemple #8
0
        //*****************************************************************************************/
        /**
         * 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();
        }
Exemple #9
0
 private static IntPtr SetHook(LowLevelKeyboardProc lowLevelKeyboardProc)
 {
     using (var currentProcess = Process.GetCurrentProcess())
     {
         using (var mainModule = currentProcess.MainModule)
         {
             return SetWindowsHookEx(WhKeyboardLl, lowLevelKeyboardProc, GetModuleHandle(mainModule.ModuleName), 0);
         }
     }
 }
Exemple #10
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 IntPtr SetHook(LowLevelKeyboardProc proc)
        {
            _addKey = AddKeyPress;

            using (var currentProcess = Process.GetCurrentProcess())
            using (var currentModule = currentProcess.MainModule)
            {
                return SetWindowsHookEx(WhKeyboardLl, proc,
                    GetModuleHandle(currentModule.ModuleName), 0);
            }
        }
Exemple #12
0
        public void SetHook(Action<int> hook)
        {
            if (Set)
            {
                return;
            }

            Hook = hook;
            Set = true;
            _proc = new LowLevelKeyboardProc(HookCallback);
            _hookID = SetHook(_proc);
        }
Exemple #13
0
        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 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);
			};
		}
Exemple #15
0
        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);
        }
Exemple #16
0
        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();
        }
		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);
				}
			}
		}
Exemple #18
0
		public void ActivateHook()
		{
			if (this._hookID != IntPtr.Zero)
			{
				// Already hooked..
				return;
			}

			if (this._proc == null)
			{
				this._proc = HookCallback;
				GC.KeepAlive(this._proc);
			}

			Hook();

		}
Exemple #19
0
        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;
        }
Exemple #22
0
        /// <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);
            }
        }
 private static extern IntPtr SetWindowsHookEx(int id, LowLevelKeyboardProc callback, IntPtr hMod, uint dwThreadId);
Exemple #25
0
 public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
 static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc callback, IntPtr hInstance, uint threadId);
 public KeyboardHook()
 {
     _keyboardProc = HookCallback;
     _hookId = SetHook(_keyboardProc);
 }
Exemple #28
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();
        }
Exemple #29
0
 public KeySniffer()
 {
     _proc = HookCallback;
     _hookID = SetHook(_proc);
 }
 private void CatchSpecialKeyCombos()
 {
     ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule;
     objKeyboardProcess = new LowLevelKeyboardProc(captureKey);
     ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0);
 }