顶部的虚拟键盘

时间:2013-03-04 05:22:32

标签: c# wpf touch

我们将使用自定义键(无Ctrl,Alt和...)创建虚拟键盘(在屏幕键盘上)。 问题是当我们将应用程序设置为Topmost="Ture"时,就无法找到最后一个活动应用程序的窗口来将选定的密钥发送给它。 (键盘应用程序现在是活动的。) 我们做了一些搜索但找不到任何有用的东西。

2 个答案:

答案 0 :(得分:3)

在将属性设置为true之前保留最后一个窗口的句柄,查看GetForegroundWindow()GetActiveWindow(),然后使用SetActiveWindow()将其设置为完成后你的键盘应用程序。

using System;
using System.Runtime.InteropServices;

namespace Foreground {
  class GetForegroundWindowTest {

    [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
    public static extern IntPtr GetForegroundWindow();

    public static void Main(string[] args){
        IntPtr fg = GetForegroundWindow(); //use to keep the last active window
        // set the topmost property to your keyboard        
        //Set fg to be active again when needed using SetActiveWindow()
    }
  }
}

答案 1 :(得分:0)

感谢您的帮助和解答。 我找到了Wosk,它解决了我的问题。 您可以查看代码。

相关问题