sendmessage如何发送键盘消息,以控制另外一个程序(100分)

  • 主题发起人 主题发起人 washhxt
  • 开始时间 开始时间
W

washhxt

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在程序中控制另外一个程序,就象在该程序中用键盘,鼠标控制,但是不成功,<br>不知道lparam该如何设置。<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp;wparam,lparam:integer;<br>&nbsp;hwnd1:HWND;<br>begin<br>&nbsp;wparam:=VK_F1;<br>&nbsp;lparam:=0;<br>&nbsp;hwnd1:=FindWindow(nil,PCHAR('UltraEdit-32 - [Edit1]'));<br>sendmessage(hwnd1,WM_KEYDOWN,wparam,lparam);<br>end;<br><br><br>
 
搜索一下吧,站内的帖子很多.
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp;wparam,lparam:integer;<br>&nbsp;hwnd1:HWND;<br>begin<br>&nbsp;wparam:=VK_F1;<br>&nbsp;lparam:=0;<br>&nbsp;hwnd1:=FindWindow(nil,PCHAR('UltraEdit-32 - [Edit1]'));<br>&nbsp;sendmessage(hwnd1,WM_KEYDOWN,WM_RETURN{回车键},0{无所谓});<br>end;<br>
 
你想干什么啊?<br><br>我有Winswos窗口管理器程序。是关于Windows Api 和Windows 消息的。<br>你要参考吗?
 
to 天宇天蓝,可以给我参考一下嘛?delphilai@163.com,谢谢
 
我只把找码给你好吗。需要什么控件,你自己加可以吗?
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; wparam,lparam:integer;<br>&nbsp; hwnd1:HWND;<br>begin<br>&nbsp; wparam:=VK_F1;<br>&nbsp; lparam:=0;<br>&nbsp; hwnd1:=FindWindow(nil,PCHAR('aa.txt - 記事本'));<br><br>&nbsp; PostMessage(hwnd1, WM_KEYDOWN, wParam, lParam);<br>&nbsp; PostMessage(hwnd1, WM_KEYUP, wParam, lParam);<br>&nbsp; SetActiveWindow(hwnd1);<br>end;
 
stringgrid1.SetFocus ;<br>&nbsp; &nbsp;postmessage(stringgrid1.Handle ,wm_keydown,vk_up,0);//在stringgrid1上按up键
 

Similar threads

后退
顶部