速
速查手册
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button4Click(Sender: TObject);<br>var<br> Wnd: HWND;<br> WinPos: TRect;<br> xy: TPoint;<br>begin<br><br> Wnd := FindWindow(nil,'CAXA电子图板文件浏览器');<br> if Wnd <> 0 then<br> begin<br> SetForegroundWindow(Wnd);<br> GetWindowRect(Wnd,WinPos);<br> xy.x := WinPos.Left + 20;<br> xy.y := WinPos.Top + 45; //(20,45)是工具条上'打开'按钮的相对位置。<br> SetCursorPos(xy.x,xy.y);<br> Mouse_Event(MOUSEEVENTF_LEFTDown,xy.x,xy.y,0,0);<br> Mouse_Event(MOUSEEVENTF_LEFTUP, xy.x,xy.y,0,0);<br><br> sleep(2000);<br> wnd := 0;<br> while wnd = 0 do<br> begin<br> Wnd := FindWindow(nil,'打开');<br> end;<br><br> cnt := 1;<br> EnumChildWindows(Wnd,@EnumerateChildWindows,0);<br><br> SetForegroundWindow(Wnd);<br> GetWindowRect(Wnd,WinPos);<br> xy.x := WinPos.Left + 380; //(380,200)是'确定'按钮在窗口内的相对位置。<br> xy.y := WinPos.Top + 200;<br> SetCursorPos(xy.x,xy.y);<br> Mouse_Event(MOUSEEVENTF_LEFTDown,xy.x,xy.y,0,0);<br> Mouse_Event(MOUSEEVENTF_LEFTUP, xy.x,xy.y,0,0);<br><br><br> end<br> else ShowMessage('window not found');<br><br>end;<br>//---------------------------------------------------------------------------<br>function EnumerateChildWindows(hWnd: HWND; lParam: LPARAM): BOOL;<br>var<br> i : integer;<br> tempStr : string;<br> ClassName: Array[0..255] of char;<br>begin<br> i := 0;<br> GetClassName(hWnd,ClassName,255);<br><br> if Pos('EDIT',UpperCase(StrPas(ClassName))) > 0 then<br> begin<br> Inc(cnt);<br> case cnt of<br> 2:<br> SendMessage(Hwnd,WM_SETTEXT,0,LongInt(pchar(exbFileName))); //写上文件名<br> end;<br><br> end;<br><br> Result:=TRUE;<br>end;