调用输入法的的api函数

sky1314 2007-04-13 11:01:11
本题为MS项目组给我们公司的考核题:(自认为自己很牛,和无所不能者来试试!)

需要在程序中不使用键盘,但是要输入数据(对系统中已有的输入法都要有一个展示的功能),所以要调用API

请讲解详细一点,有可通过的解决方案最好!

本人MSN sunshina1314@hotmail.com 有什么不清楚问我!
...全文
441 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
sky1314 2007-04-13
  • 打赏
  • 举报
回复
只好自己狂顶自己了,!!
我顶我顶顶顶!!!
sky1314 2007-04-13
  • 打赏
  • 举报
回复
怎么没人知道呢!~~
大家都在睡觉!~~
LoveCleverDog 2007-04-13
  • 打赏
  • 举报
回复
up
CathySun118 2007-04-13
  • 打赏
  • 举报
回复
不明白,帮顶
sky1314 2007-04-13
  • 打赏
  • 举报
回复
大家帮帮忙啊,小弟好晕,想睡觉了,都快
sky1314 2007-04-13
  • 打赏
  • 举报
回复
类似于这样



[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, string lParam);
[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
public void SendMsgToNote(string _sendVal)
{
string _parentWindow = "无标题 - Notepad2";
string _class = "Scintilla";
string _control = "";
const int WM_COPYDATA = 0x004A;
IntPtr _hwnd_win;
IntPtr _hwnd_textbox = new IntPtr(0);
_hwnd_win = FindWindow(null, _parentWindow);
_hwnd_textbox = FindWindowEx(_hwnd_win, _hwnd_textbox, _class, _control);
PostMessage(_hwnd_textbox, WM_COPYDATA, IntPtr.Zero, _sendVal);
}
我用调用SendMsgToNote(string _sendVal);就可以往打开的记事本里面写入字符串"_sendVal" 不过这是一个没有调通的方法我在网上找到的,
ufoteam 2007-04-13
  • 打赏
  • 举报
回复
不明白你说什么。不用键盘输入数据就用鼠标咯,还可以用触摸屏
tesling 2007-04-13
  • 打赏
  • 举报
回复
jf
tesling 2007-04-13
  • 打赏
  • 举报
回复
完全没有头绪
北京的雾霾天 2007-04-13
  • 打赏
  • 举报
回复
什么意义呢!
江城老温 2007-04-13
  • 打赏
  • 举报
回复
sofa,挖个坑先。
sky1314 2007-04-13
  • 打赏
  • 举报
回复
毛有人知道啊~~~~~~~~
sky1314 2007-04-13
  • 打赏
  • 举报
回复
楼上的那哥们,
还在嘛,
API 要求用的是IMM32(控制输入法的一个DLL),而且要求我们只能用它来操作!

类似
[DllImport("imm32.dll", EntryPoint = "ImmGetConversionStatus")]
public static extern bool ImmGetConversionStatus(
IntPtr himc,
ref IntPtr lpdw,
ref IntPtr lpdw2
);
我通过这个方法得到当前输入的状态!

所以只能用Imm32.dll 这里面的东西(来实现输出一个串"afs"类似这类的)!!
期待您的声音!!
在线等待!
sun900 2007-04-13
  • 打赏
  • 举报
回复
首先需要有输入法开放API才可以调用.
向打开的记事本输入字符串
可以用 System.Windows.Forms.SendKeys.Send("要输入的字符串");

前提是要输入的位置有焦点才可以
没有焦点输入,就是你代码里用到的消息发送,指定窗口的句柄就可以
Red_angelX 2007-04-13
  • 打赏
  • 举报
回复
都不知道你在说什么
sky1314 2007-04-13
  • 打赏
  • 举报
回复
怎么就没有知道啊,!
bomdy 2007-04-13
  • 打赏
  • 举报
回复
bd
zhulei2008 2007-04-13
  • 打赏
  • 举报
回复
不知道帮顶

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧