devshift / jnativehook

Automatically exported from code.google.com/p/jnativehook
0 stars 0 forks source link

JNative hook does not capture keyboard events when working inside a remote machine using RDP (remote desktop) on windows #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Use JNativehook on a windows machine. Launch a remote desktop session to 
another machine (maybe an ec2 machine or otherwise). 
Notice that the keyboard events for the keys pressed in the remote machine 
while the machine is in full screen mode are not captured. If you toggle the  
full screen mode, then they are captured. You can toggle the modes using Ctrl + 
Shift + Break key (if your keyboard has a break key).
Any workaround/fix for this issue is highly appreciated.
Thanks.

Original issue reported on code.google.com by hkumar.a...@gmail.com on 21 Jan 2013 at 2:26

GoogleCodeExporter commented 9 years ago
This can be tested with the sample app present at: 
http://code.google.com/p/jnativehook/downloads/list

Original comment by hkumar.a...@gmail.com on 21 Jan 2013 at 2:27

GoogleCodeExporter commented 9 years ago
What machine are you running JNativeHook on?  The remove machine you are 
connecting to or the local machine running the remove desktop client?  

One of two possibilities is happening.  First if the JNativeHook library is 
running on the remove machine, Microsoft is inserting key events at a higher 
level than JNativeHook is listening at.  It maybe possible to fix that problem 
but it would be unlikely due to the way that windows provides event hooks.

The other possibility is that you are running JNativeHook on the local machine 
and Microsoft is removing key events from a lower level than I am currently 
listening at.  This would be impossible to fix because the events would be 
removed from the event queue prior to being delivered to my code. 

I would need to know what computer is running the library to test and determine 
if it is possible to fix this problem.

Original comment by a...@1stleg.com on 22 Jan 2013 at 4:41

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for the reply.

I have tested it on different OS'es. JNativeHook should be running on the
local machine and NOT the remote machine.
I have used both Windows 7 and Windows XP. The remote machine was running
Windows 2003 server.
Note that, if the remote machine is  NOT in the full screen mode everything
works fine.
Its only when you make the remote machine as full screen, JNativeHook stops
capturing.
By full screen mode I mean the case when you dont see the host (local)
machine's task bar at all and are seeing the desktop of the remote machine
only.

Let me know what additional details do you want.

Thanks again.

Thanks & Regards
Hemant

Original comment by hkumar.a...@gmail.com on 22 Jan 2013 at 4:52

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hemant,

Thanks for the quick response.  It sounds like this will not be possible to 
fix, however, I will take a look into it in case I missed something. 

Original comment by a...@1stleg.com on 22 Jan 2013 at 4:55

GoogleCodeExporter commented 9 years ago
Hi,

Could you give me a clue as to why does it work in the non-full screen mode
and not on full-screen ?
I could explore it further !

Thanks & Regards
Hemant

Original comment by hkumar.a...@gmail.com on 22 Jan 2013 at 5:00

GoogleCodeExporter commented 9 years ago
For the keyboard hook on windows, jnativehook uses the SetWindowsHookEx with 
WH_KEYBOARD_LL and WH_MOUSE_LL.  These are the lowest level keyboard hooks that 
can be installed via the Windows API.  I am guessing that when in full screen 
mode, Microsoft has probably decided to get keyboard input directly (from the 
kernel?) and bypassed their own API for event delivery... You could try 
implementing a workaround near 
[https://code.google.com/p/jnativehook/source/browse/branches/1.1/src/native/win
dows/NativeThread.c#482 line 482] but I am not sure if anything can be done.  
The only thing I can think of is dll injection directly into the RDP client 
application but that will be difficult and wont work for any other application.

Original comment by a...@1stleg.com on 22 Jan 2013 at 5:16

GoogleCodeExporter commented 9 years ago
Thanks. Will take a look. Will revert in case I can think of something. Do
let me know in case you come up with something.

Thanks & Regards
Hemant

Original comment by hkumar.a...@gmail.com on 22 Jan 2013 at 5:21

GoogleCodeExporter commented 9 years ago
Just an update.  The only information I have found regarding this problem is 
outlined here:  
http://stackoverflow.com/questions/14596117/setwindowshookex-wm-keyboard-ll-not-
coming-through-with-full-screen-rdc/14613658

I have not tested their proposed solution so no idea if it will even work.  You 
maybe able to test it in java by restarting the native hook in some kind of 
timer and opening RDP in full screen, then wait and see if it receives any 
events.

Original comment by a...@1stleg.com on 1 Mar 2013 at 12:28

GoogleCodeExporter commented 9 years ago
I know it has been close to forever, but this bug is now fixed in the trunk.  
See issue https://github.com/kwhat/jnativehook/issues/30 for more information.

Original comment by a...@1stleg.com on 2 Jan 2015 at 6:24