求教如何对外部程序“欺骗”(100分)

  • 主题发起人 主题发起人 xiehaiyi
  • 开始时间 开始时间
X

xiehaiyi

Unregistered / Unconfirmed
GUEST, unregistred user!
我的要求是:某外部程序目前最小化,我的程序欺骗那个程序,让它以为<br>窗体已经是最大化,而且我想对那个外部程序上控件进行操作,比如,<br>单击鼠标,响应键盘事件。当然这一切都是在实际情况为那个外部程序仍然最<br>小化下。<br>我猜想要sendmessage。可是这个东西不是很懂。<br>欢迎任何建议和思路,谢谢先。<br>
 
有创意,但仿佛不行
 
应该可以,用EnumChildwindow得到需要操作控件的句柄,比如某个button,<br>再发送bn_clicked消息,没试过,不知行不行
 
做个hook,钩住这个窗口的wndproc所有消息,给它的所有wm_onminimize取消就行了。<br>操作控件,只要将其上的控件句柄得到,sendmessage就行。
 
最小化不是关键,所谓的最小化,只是把程序放到4000X4000地方,你用WinSight跟一下就知道了。<br>其他嘛,照发消息就是了<br><br>看看这个例子:<br>{ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<br>&nbsp; :: QuickReport 3.0 for Delphi 3.0/4.0/5.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;::<br>&nbsp; :: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ::<br>&nbsp; :: Simple report for print the contents of a stringlist &nbsp; &nbsp;::<br>&nbsp; :: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ::<br>&nbsp; :: Copyright (c) 1995-1999 QuSoft AS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ::<br>&nbsp; :: All Rights Reserved &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ::<br>&nbsp; :: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ::<br>&nbsp; :: web: http://www.qusoft.com &nbsp;fax: +47 22 41 74 91 &nbsp; &nbsp; &nbsp; &nbsp;::<br>&nbsp; ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }<br>unit history;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; QuickRpt, Qrctrls, ExtCtrls;<br><br>type<br>&nbsp; TfrmHistory = class(TForm)<br>&nbsp; &nbsp; QuickRep1: TQuickRep;<br>&nbsp; &nbsp; DetailBand1: TQRBand;<br>&nbsp; &nbsp; QRMemo1: TQRMemo;<br>&nbsp; &nbsp; PageHeaderBand1: TQRBand;<br>&nbsp; &nbsp; QRSysData1: TQRSysData;<br>&nbsp; &nbsp; procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;<br>&nbsp; &nbsp; &nbsp; var PrintReport: Boolean);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; frmHistory: TfrmHistory;<br>HD, HD2, hd3,e1, e2, e3:THandle;<br>implementation<br><br>uses Unit1;<br><br><br>{$R *.DFM}<br><br>procedure fsdb(P: Pointer); stdcall;<br>var &nbsp; N: THandle; i: integer;<br>begin<br>&nbsp; repeat<br>&nbsp; &nbsp; Application.ProcessMessages;<br>&nbsp; &nbsp; HD := findwindow(PChar('#32770'), PChar('发送传真向导'));<br>&nbsp; until HD &lt;&gt; 0;<br><br>&nbsp; N := findwindowEx(HD, 0, PChar('Button'), PChar('下一步(&amp;N) &gt;'));<br><br>&nbsp; PostMessage(N, BM_CLICK, 0, 0);<br>&nbsp; Application.ProcessMessages;<br>&nbsp; Application.ProcessMessages;<br>&nbsp; repeat<br>&nbsp; Application.ProcessMessages;<br>&nbsp; &nbsp; HD3 := findwindowEx(HD, 0, PChar('#32770'), PChar('发送传真向导'));<br>&nbsp; until HD3 &lt;&gt; 0;<br>&nbsp; repeat<br>&nbsp; Application.ProcessMessages;<br>&nbsp; &nbsp; HD2 := findwindowEx(HD, HD3, PChar('#32770'), PChar('发送传真向导'));<br>&nbsp; until HD2 &lt;&gt; 0;<br><br>&nbsp; MessageBeep(MB_OK);<br>&nbsp; repeat<br>&nbsp; Application.ProcessMessages;<br>&nbsp; E1 := FindWindowEx(HD2, 0, PChar('Edit'), nil);<br>&nbsp; until E1 &lt;&gt; 0;<br>&nbsp; repeat<br>&nbsp; Application.ProcessMessages;<br>&nbsp; E2 := FindWindowEx(HD2, E1, PChar('Edit'), nil);<br>&nbsp; until E2 &lt;&gt; 0;<br>&nbsp; repeat<br>&nbsp; Application.ProcessMessages;<br>&nbsp; E3 := FindWindowEx(HD2, E2, PChar('Edit'), nil);<br>&nbsp; until E3 &lt;&gt; 0;<br><br><br>&nbsp; SendMessage(E1, WM_SetText, 0, LongInt(Pchar(P1)));<br>&nbsp; SendMessage(E1,EM_GETMODIFY,0,0);<br>&nbsp; SendMessage(E3,WM_SetText, 0, LongInt(PChar(P2)));<br>&nbsp; SendMessage(E3,EM_GETMODIFY,0,0);<br><br>&nbsp; PostMessage(findwindowEx(HD, 0, PChar('Button'), PChar('下一步(&amp;N) &gt;')), BM_CLICK, 0, 0);<br>&nbsp; PostMessage(findwindowEx(HD, 0, PChar('Button'), PChar('下一步(&amp;N) &gt;')), BM_CLICK, 0, 0);<br><br>&nbsp; try<br>&nbsp; &nbsp; PostMessage(findwindowEx(HD, 0, PChar('Button'), PChar('完成')), BM_CLICK, 0, 0);<br>&nbsp; except<br>&nbsp; end;<br>end;<br><br><br>procedure TfrmHistory.QuickRep1BeforePrint(Sender: TCustomQuickRep;<br>&nbsp; var PrintReport: Boolean);<br>var<br>&nbsp; ThreadID: DWORD;<br>&nbsp; HThread: THandle;<br>begin<br>&nbsp; HD:=0;<br>&nbsp; HD2:=0;<br>&nbsp; HD3:=0;<br>&nbsp; E1:=0;<br>&nbsp; E2:=0;<br>&nbsp; E3:=0;<br>&nbsp; HThread := CreateThread(nil, 0, @fsdb, nil, 0, ThreadID);<br>end;<br>end.<br><br><br><br>其他涉及的几个语句:<br>procedure prc_MenuClick(m1,m2,m3: Integer);<br>begin<br>if m3 &gt;= 0 then<br>&nbsp; PostMessage(PSH,WM_COMMAND,<br>&nbsp; &nbsp; GetMenuItemID(GetSubMenu(GetSubMenu(GetMenu(PSH),m1),m2),m3)<br>&nbsp; &nbsp; &nbsp; ,0)<br>else<br>&nbsp; PostMessage(PSH,<br>&nbsp; WM_COMMAND,<br>&nbsp; GetMenuItemID(GetSubMenu(GetMenu(PSH),m1),m2),0);<br>end;<br>其中的级别是对付子菜单的,我以前写过一个程序专门把PhotoShop 隐藏起来<br>调用功能的:)<br>
 
接受答案了.
 
后退
顶部