Hi,
Is there any way to query whether or not a keyboard is attached to a pc
please?
My software will be running on XP/Vista systems in an environment where
there may or may not be a keyboard/mouse attached to the system.
thank you
ModelBuilder - 19 Jul 2007 14:04 GMT
I don't know the answer to the question, but I would not think it was
necessary to know the answer to accomplish what you are required to do.
If you have some code XYZ that needs to be executed at some time by a user
action, then presumably the code is executed from some event handler, such as
a button click or keyboard shortcut. It sounds like you will need to make
sure that there is some form of handler for setups where neither of these
could occur, perhaps from a voice activation event? Your mouse and keyboard
handlers just won't be called in this configuration.
> Hi,
> Is there any way to query whether or not a keyboard is attached to a pc
[quoted text clipped - 3 lines]
>
> thank you
Ben Voigt [C++ MVP] - 19 Jul 2007 16:06 GMT
> Hi,
> Is there any way to query whether or not a keyboard is attached to a pc
> please?
SetupDiCreateDeviceInfoList passing GUID_DEVCLASS_KEYBOARD
I highly recommend using C++/CLI for this as C# code for using C-style
structures with pointers is somewhat unwieldy.
> My software will be running on XP/Vista systems in an environment where
> there may or may not be a keyboard/mouse attached to the system.
>
> thank you
Peter Bromberg [C# MVP] - 19 Jul 2007 16:36 GMT
Forgive me for sounding simplistic, but if there is no keyboard / mouse
attached to a machine running your program then how do you propose to get
user input?
The "sounds" like the classic joke,
"Keyboard not found. Press F1 to continue."
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com
> Hi,
> Is there any way to query whether or not a keyboard is attached to a pc
[quoted text clipped - 3 lines]
>
> thank you
Ben Voigt [C++ MVP] - 19 Jul 2007 17:09 GMT
> Forgive me for sounding simplistic, but if there is no keyboard / mouse
> attached to a machine running your program then how do you propose to get
> user input?
> The "sounds" like the classic joke,
>
> "Keyboard not found. Press F1 to continue."
Knowing there is no keyboard... might help prevent such paradoxes. A
timeout could be substituted.
> -- Peter
> Recursion: see Recursion
[quoted text clipped - 9 lines]
>>
>> thank you
ModelBuilder - 19 Jul 2007 17:24 GMT
Obviously it will come from the same way the user launched the program... :)
> Forgive me for sounding simplistic, but if there is no keyboard / mouse
> attached to a machine running your program then how do you propose to get
[quoted text clipped - 16 lines]
> >
> > thank you
Claire - 20 Jul 2007 09:05 GMT
Lol! in reply to comments about keyboards/mice.
My application is written for touch screen and operates in different modes
depending on user type logging into the system.
Regular users log in at reception using a card via a cardreader and have a
touch screen, admins would normally have an installation with mouse and
keyboard.
I thought it would be nicer to test whether hardware was absent and display
an onscreen keyboard automatically rather than force someone to press an
onscreen button to access it.
thank you :)
Tim Sprout - 20 Jul 2007 17:40 GMT
> Hi,
> Is there any way to query whether or not a keyboard is attached to a pc
[quoted text clipped - 3 lines]
>
> thank you
Would the WMI class Win32_Keyboard be useful in this case?
http://msdn2.microsoft.com/en-US/library/aa394166.aspx
-Tim Sprout