如何将delphi的一个参数传给另一个exe上的编辑框,并执行那个编辑框的enter操作?(100分)

  • 主题发起人 主题发起人 fancypansy
  • 开始时间 开始时间
F

fancypansy

Unregistered / Unconfirmed
GUEST, unregistred user!
那个exe是别人写的,没有代码,界面上放有一个编辑框,此编辑框有enter事件,<br>我在自己的delphi 程序中使用shellexcute来调用那个exe文件。问题是:我如何将参数传给那个编辑框,并执行编辑框的enter事件呢?<br>请高手帮忙!<br>在线等,万分感谢!
 
用消息吧。找找资料。
 
http://topic.csdn.net/t/20050908/19/4258227.html#<br>参考一下吧。
 
用窗体绑架技术可以实现。
 
luoyanqing119:可否说得详细点?
 
首先你可以使用FindWindow,GetWindow 等手段得到程序(form)的句柄<br>然后再用SendMessage或PostMessage的方法,将字符串传过去。<br>以下一段例子是将PhotoShop 打开并点击某菜单,在弹出的窗口中<br>选择一段字符串,并将它改变的例子<br><br>function fun_GetImageSize: TImageSize;<br>var<br>&nbsp; ISH: THandle;<br>&nbsp; CancelHandle: THandle;<br>&nbsp; WidthHandle : THandle;<br>&nbsp; HeightHandle: THandle;<br>&nbsp; TextW: array [0..255] of Char;<br>&nbsp; TextH: array [0..255] of Char;<br>begin<br>&nbsp; // Step 1: Call PS to show the 'Image Size' dialog.<br>&nbsp; prc_MenuClick(2,8,-1);<br>&nbsp; // Step 2: If success,get the two Edit's handles.<br>&nbsp; repeat<br>&nbsp; &nbsp; Application.ProcessMessages;<br>&nbsp; &nbsp; ISH:= FindWindow(PChar('PSFloatC'),PChar('Image Size'));<br>&nbsp; until &nbsp;ISH &lt;&gt; 0 ;<br><br>&nbsp; repeat<br>&nbsp; &nbsp; Application.ProcessMessages;<br>&nbsp; &nbsp; CancelHandle:= FindWindowEx(ISH,0,PChar('Button'),Pchar('Cancel'));<br>&nbsp; &nbsp; WidthHandle:= FindWindowEx(ISH,0,PChar('Edit'),nil);<br>&nbsp; &nbsp; HeightHandle:= FindWindowEx(ISH,WidthHandle,PChar('Edit'),nil);<br>&nbsp; Until ((CancelHandle&lt;&gt;0) and &nbsp;(WidthHandle&lt;&gt;0) and (HeightHandle&lt;&gt;0));<br><br>&nbsp; SendMessage(WidthHandle,WM_GETTEXT,Sizeof(TextW),LongInt(@TextW));<br>&nbsp; SendMessage(HeightHandle,WM_GETTEXT,Sizeof(TextH),LongInt(@TextH));<br>&nbsp; Form1.Hint:= TextW;<br>&nbsp; Result.X:= StrToInt(Form1.Hint);<br>&nbsp; Form1.Hint:= TextH;<br>&nbsp; Result.Y:= StrToInt(Form1.Hint);<br>&nbsp; Form1.Hint:='';<br>&nbsp; PostMessage(CancelHandle,BM_CLICK,0,0); //After Use, Close it.<br><br>end;
 
多人接受答案了。
 
后退
顶部