如何决定是否在Windows中显示虚拟键盘?

如何决定是否在Windows中显示虚拟键盘?,windows,delphi,winapi,touch,Windows,Delphi,Winapi,Touch,如何自动决定是否在Windows中显示虚拟键盘 我们正在应用程序中添加对手势和虚拟键盘的支持,但不希望在我连接了真实键盘时看到虚拟键盘 谢谢大家! 更新:RRUZ(没有win8平板电脑)提出了一个有用的建议,但没有起作用,因为win8平板电脑的性能不符合预期 To get the number of keyboards present in the system you can use the Win32_Keyboard WMI class. Try this sample {$APPTY

如何自动决定是否在Windows中显示虚拟键盘

我们正在应用程序中添加对手势和虚拟键盘的支持,但不希望在我连接了真实键盘时看到虚拟键盘

谢谢大家!

更新:RRUZ(没有win8平板电脑)提出了一个有用的建议,但没有起作用,因为win8平板电脑的性能不符合预期

To get the number of keyboards present in the system you can use the Win32_Keyboard WMI class.

Try this sample

{$APPTYPE CONSOLE}

uses
  SysUtils,
  ActiveX,
  ComObj,
  Variants;

function  GetKeyboardCount : integer;
var
  FSWbemLocator : OLEVariant;
  FWMIService   : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject   : OLEVariant;
  oEnum         : IEnumvariant;
  iValue        : LongWord;
begin;
  Result:=0;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService   := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', '', '');
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT DeviceID FROM Win32_Keyboard','WQL', $00000020);
  oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  while oEnum.Next(1, FWbemObject, iValue) = 0 do
  begin
    Inc(Result);
    FWbemObject:=Unassigned;
  end;
end;

begin
 try
    CoInitialize(nil);
    try
      Writeln(Format('Keyboards %d', [GetKeyboardCount]));
    finally
      CoUninitialize;
    end;
 except
    on E:EOleException do
        Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
    on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;
end.

根据我的经验,这在现实世界中不会有帮助:在我的Win8 tablet设备管理器上,报告了一个PS/2键盘(!!),所以像这样的函数永远不会告诉你没有键盘Giel 9小时前

您是否在询问如何检测是否有键盘设备连接到机器(以确定没有连接键盘的触摸设备)?您可以在
TEdit
中设置双击作为触发器,以显示Virtualak键盘,并建议用户可以这样做。@TLama:是的。EASI:delphi中出现的带有触摸支持的虚拟kyd不够好。我们试着先用它。