[Tutor] Virtual keyboard
Alan G
alan.gauld at freenet.co.uk
Thu Jul 14 12:43:36 CEST 2005
>> If you want your virtual keyboard to type in any program you will
>> have to
>> deal with focus issues and it seems to me that would be hard, if
>> possible.
>
> I do want it to type in any entry (websites, notepad and other
> programs), and thats what makes it harder. I dont think that
> shouldnt
> be too hard as well, but I have no idea how to do it.
Assuming you are on Windows - and this is very platform specific -
then
you need to access the Windows API using either winall or ctypes.
The API calls you should look at (on msdn.microsoft.com) are:
HWND GetFocus(VOID)
to get a handle to the window which currently has focus.
and
BOOL PostMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
Where Msg could be:
WM_KEYDOWN
Which has the following wParam and lParam values:
nVirtKey = (int) wParam; // virtual-key code
lKeyData = lParam; // key data
So you are right its not too doifficult but does require fairly
low level access to Windows. Sufficiently so that personally I'd
build this using Delphi even though it is possible in Python!
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list