一个很老的经典问题!delphi发送组合键,欢迎大家来讨论。(100分)

  • 主题发起人 主题发起人 鸢都剑客
  • 开始时间 开始时间
我明天 用 AccExplorer32 试试 <br>应该 可以 直接 触发他的 菜单项 <br>而不是 模拟 输入
 
估计 要用到 Oleacc.dll<br>俺在 查资料
 
to:hfghfghfg,<br>你是潍坊的吗,哪里的啊,我是坊子的.我要实现组合键是为了做一个游戏辅助软件,不是针对记事本,我用postmessage 已实现对游戏发送字符串,发送回车键等,就是没实现ALT的组合键.别外我用发送按下ALT,按下F,弹起F,弹起ALT.也达不到效果.
 
看来还是没人来啊,呵呵,我帮楼主顶起,持续关注
 
keybd_event 不分程序的,只要有处于激活状态的,可以接受按键操作的程序就行,没有也不会出错的,他好像是直接将按键信息发送当前激活状态程序的键盘缓冲区的
 
to: Mr_Luan,<br>我要的是局部的.针对某个程序发送,不是全局的.
 
两个窗口 form1、form2 <br>在 form1 放 Button1、Button2 加上下面的程序 <br>在 form2 放 memo1<br>无论 form2 是否 Show,Memo1 都会被 Ctrl + v<br><br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Memo1: TMemo;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>uses Unit2;<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; form2.Show;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; keyboardState: TKeyBoardState;<br>&nbsp; hWnd:HWnd;<br>begin<br>&nbsp; hWnd:= form2.memo1.Handle;<br>&nbsp; keyboardState[17] := 129;<br>&nbsp; SetKeyBoardState(keyboardState);<br>&nbsp; PostMessage(hWnd, 256, 86, 1);<br>&nbsp; Application.ProcessMessages;<br>&nbsp; keyboardState[17] := 0;<br>&nbsp; SetKeyBoardState(keyboardState);<br>end;<br><br>end.
 
看看是否可以参考一下
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部