安
安情
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br> function GetButtonHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br> buffer1: array[0..255] of Char;<br>begin<br> Result := True;<br> //PInteger(lparam)^ := 0;<br> //showmessage(inttostr(lparam)); //<br> GetClassName(hwnd,buffer,256);<br> //ShowMessage(StrPas(Buffer));<br> if strpas(Buffer)='Button' then //<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> //ShowMessage(StrPas(buffer1));<br> if strpas(buffer1) = '分析' then //<br> begin<br> PInteger(lparam)^ := hwnd;<br><br> Result:=False;<br> end;<br> end;<br>end;//end of function<br><br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br><br> var<br> ButtonHandle,WindowHandle:HWND;<br>begin<br> //以下代码是为了得到“确定”按钮的句柄<br> WindowHandle:=FindWindow(nil,'计算机管理'); //<br> if WindowHandle <> 0 then<br> begin<br> EnumChildWindows(WindowHandle,@GetButtonHandle,Integer(@WindowHandle));<br> ButtonHandle := WindowHandle;<br> //以下代码是为了模拟单击“确定”按钮<br> if ButtonHandle <> 0 then<br> begin<br> showmessage(inttostr(WindowHandle));<br> PostMessage(ButtonHandle, BM_Click, 0, 0);<br> //SendMessage(ButtonHandle,MOUSEEVENTF_LEFTDOWN,0,0);<br> //SendMessage(ButtonHandle,MOUSEEVENTF_LEFTUP,0,0);<br> end;<br> end; <br>end;<br><br><br>end.<br><br>必须要手动点一下磁盘碎片整理程序,才能模拟点击分析按钮,我想自动完成,就是当打开计算机管理时,自动点击分析按钮,有谁可以帮我一下?<br>如果可以自动,我就可以把按钮事件改成时间控件了!<br>另外,我想实现,通过inputbox来输入指定汉字,然后通过枚举窗口查找哪些汉字。比如,当用迅雷下载的时候,当出现“下载完成100%”的时候,然后做一些事情,比如关机?