我一直在开发触摸屏应用程序。我需要知道是否有一个现成的触摸屏键盘,我可以使用作为我的应用程序控制器。
我试着用窗户准备的键盘,但它太小了,不适合触摸屏。
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");任何想法,如何在最短的时间内开始建造一个将是非常感谢.
新问题
我从某人那里复制了这段代码,并对其做了一些修改:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
class Win32
{
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern bool SetWindowPos(
int hWnd, // window handle
int hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags); // window positioning flags
public const int HWND_BOTTOM = 0x0001;
public const int HWND_TOP = 0x0000;
public const int SWP_NOSIZE = 0x0001;
public const int SWP_NOMOVE = 0x0002;
public const int SWP_NOZORDER = 0x0004;
public const int SWP_NOREDRAW = 0x0008;
public const int SWP_NOACTIVATE = 0x0010;
public const int SWP_FRAMECHANGED = 0x0020;
public const int SWP_SHOWWINDOW = 0x0040;
public const int SWP_HIDEWINDOW = 0x0080;
public const int SWP_NOCOPYBITS = 0x0100;
public const int SWP_NOOWNERZORDER = 0x0200;
public const int SWP_NOSENDCHANGING = 0x0400;
}
namespace Keyboard
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.KeyText.MouseDoubleClick += new MouseEventHandler(KeyText_MouseDoubleClick);
}
private Process process;
private string getKeyboardText()
{
KeyScreen k = new KeyScreen();
k.ShowDialog();
if (k.DialogResult.ToString().Equals("OK"))
return k.Text1;
else
return null;
}
void KeyText_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.KeyText.Text = getKeyboardText();
}
private void KeyBtn_Click(object sender, EventArgs e)
{
this.showKeypad();
//Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");
}
private void showKeypad()
{
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = "c:\\Windows\\system32\\osk.exe";
process.StartInfo.Arguments = "";
process.StartInfo.WorkingDirectory = "c:\\";
process.Start(); // Start Onscreen Keyboard
process.WaitForInputIdle();
Win32.SetWindowPos((int)process.MainWindowHandle,
Win32.HWND_BOTTOM,
300, 300, 1200, 600,
Win32.SWP_SHOWWINDOW | Win32.SWP_NOZORDER);
}
}
}这很好,我有一个很好的键盘(触摸屏的大小),但是,我对C#和VB一点也不熟悉.根据我显示的触摸屏键盘更改文本框中的文本。
谢谢,
发布于 2010-07-03 10:29:59
要在屏幕上创建自己的键盘,基本上需要执行以下操作。
1-创建一个windows键盘应用程序,您可以与之交互,但不窃取当前控件的输入焦点,而您目前所在的每个应用程序都在该控件中工作。
2-键盘应用程序应将按键发送到当前活动的控件,以响应对键盘应用程序中按钮的单击。
我先前提供的以下答案提供了如何使用WinForms进行此操作的简单演示。
基本上,该窗口是用无阿提样式创建的,这样可以防止窗口成为活动的和钢铁化的输入焦点。然后,响应按钮单击,它使用SendKeys向具有输入焦点的控件发送学徒键按下消息。
下面的答案显示了如何将无阿提样式应用于WPF应用程序。
试图创建一个WPF触摸屏键盘应用程序,不能让WPF应用程序发送键到另一个窗口?有什么建议吗?
除了WS_EX_NOACTIVATE之外,还有其他解决方案,但这很简单,只会在拖曳窗口时遇到一个小的表象故障。有了一些聪明的消息处理就可以克服。
发布于 2014-01-27 22:45:01
我知道这是非常非常古老的,但万一其他人的第一个想法是,Windows屏幕上的键盘太小了(这也是我的第一个想法),你实际上可以通过使窗口更大(你也可以编程)来使它变大。
+1对于这个问题和发布代码,不过,因为我正在制作一个简单的,因为我需要一个更直接的控制它从我的应用程序。
https://stackoverflow.com/questions/3171124
复制相似问题