如何截获键盘按键的消息?也谈输入法的机理

haoqingqlm 2003-01-14 11:25:56
1、取得键盘按键的消息,知道按了什么键(包括字母,字符,功能键,组合键)。
2、按下的键对其它程序无影响。就是将消息截获了。如按了字母"A"键只执行我的程序的操作,而不会在用户打开的写字板之类的程序上输入"A"。
就如输入法一样
3、顺便问一下输入法的机理。如果解决了上述两点,我又如何将我程序上的字(汉字、符号等)写到用户的写字板、记事本或是word的文本处理软件上。我试过用剪切板,可以实现第三条的写入功能,但会覆盖原来剪切板的内容。而且真的输入法不是这样实现的,也没用到剪切板。请高手指点。
希望能给出代码。haoqingqlm@163.com
...全文
222 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
ehom 2003-03-12
  • 打赏
  • 举报
回复
在CSDN文档中心输入关键字"输入法"查询
xiaohedou 2003-03-12
  • 打赏
  • 举报
回复
学习
asulor 2003-03-11
  • 打赏
  • 举报
回复
去哪里找教hook的教程??
haoqingqlm 2003-02-25
  • 打赏
  • 举报
回复
谁有用delphi编写的输入法源码,高分求购
Storm2008 2003-02-23
  • 打赏
  • 举报
回复
gz
qiume 2003-02-23
  • 打赏
  • 举报
回复
来学习的
ShadowBlade 2003-01-22
  • 打赏
  • 举报
回复
在打开输入法得时候确定焦点所在?
然后在对焦点所在得地方放入敲打得信息

TCXHL 2003-01-19
  • 打赏
  • 举报
回复
HOOK
papaya_stone 2003-01-19
  • 打赏
  • 举报
回复
输入法有自己的消息,好像是WM_IME_XXXX

自由拼音输入法,源程序
http://www.vckbase.com/code/listcode.asp?mclsid=13&sclsid=1329&page=5

johnmack 2003-01-18
  • 打赏
  • 举报
回复
1WM_CHAR;WM_KEYDOWN;WM_SYSKEYDOWN;WM_SYSCHAR;
2有一个焦点的消息忘了名字了!
snail1024 2003-01-18
  • 打赏
  • 举报
回复
好像不能区分大小写呀!
joky1981 2003-01-14
  • 打赏
  • 举报
回复
问题一:
uses
Windows, SysUtils, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Buttons, StdCtrls, ExtCtrls;

const
ctrl_A = 1; { ASCII value for Ctrl+A }
ctrl_Z = 26; { ASCII value for Ctrl+Z }

FunctionKeys: array [vk_f1 .. vk_f12] of string[3] =
('F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8',
'F9', 'F10', 'F11', 'F12');

procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
s: string;
begin
EditValue.Text:= IntToStr(Key);
s := '';

if ssShift in Shift then
s := s + 'Shift+';
if ssAlt in Shift then
s := s + 'Alt+';
if ssCtrl in Shift then
s := s + 'Ctrl+';

if Length(s) > 0 then
Delete(s, Length(s), 1);
EditShift.Text := s;
if Key in [vk_f1 .. vk_f12] then
EditChar.Text := FunctionKeys[Key]
else
EditChar.Text := '';
if Key = vk_space then
Key := 0;
end;

procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Ord(Key) in [ctrl_A .. ctrl_Z] then
EditChar.Text := '^' + Chr(Ord(Key) + Ord('A') - 1)
else
EditChar.Text := Key;
EditValue.Text := IntToStr(Ord(Key));
end;

procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
EditChar.Text := '';
EditValue.Text := '';
EditShift.Text := '';
end;

procedure TMainForm.ButtonExitClick(Sender: TObject);
begin
Application.Terminate;
end;
haoqingqlm 2003-01-14
  • 打赏
  • 举报
回复
我需要的是windows消息。在程序未active的情况下取得键盘按键!

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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