keyboard-hook

Can I change a user's keyboard input?

对着背影说爱祢 提交于 2019-12-03 16:41:03
I found this keyboard hook code, which I'm trying to slightly modify for my purposes: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx As an overview, I want to have the user press a key, say 'E', and have the keyboard return a different character, 'Z', to whatever app is in focus. The relevant method I changed now looks like: private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { //The truely typed character: int vkCode = Marshal.ReadInt32(lParam); Console.WriteLine((Keys)vkCode); KBDLLHOOKSTRUCT replacementKey

How to tell the difference between a user-tapped keyboard event and a generated one?

风格不统一 提交于 2019-12-03 12:35:50
I've installed a keyboard hook: CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) { Basically I want to take the user's keyboard taps, eat the input, and post my own input instead. So if he taps "g" I might want to post "foo" to the textfield. I'm writing to the textfield with CGEventPost and CGEventSetUnicodeString as found here: http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg23343.html The problem is that each of my programmatically entered characters is hitting the keyboard hook. So I can't return NULL in the keyboard hook to

Is it possible to use Win32 Hooks in Qt applications

可紊 提交于 2019-12-03 07:15:14
I like to know if its possible to use win32 keyboard hook function (SetWindowsHookEx , SetWindowsHookEx ) in a Qt application. If possible pls provide a sample code on using SetWindowsHookEx , SetWindowsHookEx functions in Qt. //Update as of 18 Feb 2010 // I havent figured out how to do that in QT yet. But as a workaround I have created a win32 dll using vc++ express edition and placed my hook commands inside the dll functions. And I call that dll functions from Qt using QLibrary class /* hearder file code*/ QLibrary *myLib; typedef HHOOK (*MyPrototype)(HINSTANCE); /* source file code */ myLib

Can I use Python to capture keyboard and mouse events in OSX?

牧云@^-^@ 提交于 2019-12-03 06:16:03
I'm trying to write a simple macro recorder in Python for OSX - something which can capture mouse and key events as the script runs in the background and replay them. I can use autopy for the latter, is there a similarly simple library for the former? synthesizerpatel I ran across a few solutions to this problem today and figured I'd circle back around and share here so others could save the search time. A nifty cross platform solution for simulating keyboard and mouse input: http://www.autopy.org/ I also found a brief but working (As of Mountain Lion) example of how to globally log key

Override default INT 9h

你说的曾经没有我的故事 提交于 2019-12-02 10:00:57
I'm trying to override the default interruption when a key is pressed. Here is my code : I don't understand why it doesn't work, it works with others INT numbers (43h for example) mov al,9h mov ah,25h mov bx,seg int9h mov ds,bx mov dx,offset int9h int 21h (Where int9h is a label in my code) Does anyone know how to hook the interruption when a key is pressed ? Thanks ! EDIT: mov ax,2509h mov dx,offset int9h int 21h int9h PROC ;do some stuff IRET int9h ENDP I'll try and answer this again - in a somewhat long-winded fashion. Before Windows became prevalent, DOS ruled the computer. In order to

How do you get the current keyboard state globally? (i.e. what keys are currently depressed regardless of if the inquiring application has focus)

拥有回忆 提交于 2019-12-02 06:51:37
问题 I'm writing a screen capture utility, and I'd like to be able to store the current state of the keyboard and mouse whenever a screenshot is taken. Doing this for the mouse is simple, since using the PointerInfo class in a manner described in this related question gives you the screen coordinates for the current mouse location and the click information if desired. However, I haven't been able to find an analog to this class for the keyboard; all the keyboard related classes appear to be focus

How do I replace a keystroke with jQuery?

心不动则不痛 提交于 2019-12-02 04:19:15
问题 I need to be able to replace a keystroke with jQuery. When the right arrow is pressed, I want the tab key to be pressed instead. So far I have: <script type="text/javascript" src="jquery-1.6.1.min.js"></script> <script type="text/javascript" src="jquery.simulate.js"></script> <script type="text/javascript"> $(function () { $("select").each( function() { $(this).keydown(function(event) { if (event.which == '39') { $(this).simulate("keydown", { keyCode: 9, ctrlKey: false, shirtKey: false }); $

How to know if the keyboard is active on a text input

戏子无情 提交于 2019-12-02 04:01:47
I have an application that acts like an on screen keyboard, I need it to know if there is a keyboard cursor (caret) active any where, so the keyboard will set to active. I have searched for keyboard hooks and winapi, but I couldn't find the proper method to use. To simplify my problem, I need my application to be active if the user can press on the real keyboard and print text on the computer. It is easy by searching for the caret position, since it should be larger than 0 GUITHREADINFO lpgui = new GUITHREADINFO(); IntPtr fore = GetForegroundWindow(); uint tpid = GetWindowThreadProcessId(fore,

Using a low-level keyboard hook to change keyboard characters

老子叫甜甜 提交于 2019-12-02 01:45:47
问题 I'm creating a custom keyboard layout. As the beginning step, I want to have the user press a key, have my keyboard hook intercept it, and output a different key of my choosing. I found this keyboard hook code, which I'm trying to slightly modify for my purposes: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx I've changed the relevant method to this: private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) {

How do you get the current keyboard state globally? (i.e. what keys are currently depressed regardless of if the inquiring application has focus)

Deadly 提交于 2019-12-02 00:17:39
I'm writing a screen capture utility, and I'd like to be able to store the current state of the keyboard and mouse whenever a screenshot is taken. Doing this for the mouse is simple, since using the PointerInfo class in a manner described in this related question gives you the screen coordinates for the current mouse location and the click information if desired. However, I haven't been able to find an analog to this class for the keyboard; all the keyboard related classes appear to be focus specific. So, is there a way to get the current keyboard state in Java? P.S. Remember that I'm looking