1.定位窗口
1 fHwnd:=FindWindow(nil,'短信中心');
2
3 if fHwnd=0 then
4
5 begin showmessage('请先登录飞信2013短信中心'); exit; end;
6
7 { application.CreateForm(Tpanel,fHwnd);
8
9 panel3:= Tpanel.Create(application);
10
11 panel3.ParentWindow:=panel2.ParentWindow;
12
13 panel3.Dock(panel2,Boundsrect); 2013-3-23 }
14
15 if fHwnd>0 then SendMessage(fHwnd,WM_SYSCOMMAND,SC_RESTORE,0);// 窗口最大化
16
17 Feition(g_tel,Memo1.text);
2.发送(Postmessage的运用)
1 //author:吴chyuan 2013.1.2 2 3 procedure Feition(tel:string;fetionmsg:string); 4 5 var 6 7 i:integer; 8 9 pj:string; 10 11 fHwnd:THandle; 12 13 cHwnd3,cHwnd2,cHwnd1,cHwnd:HWND; 14 15 begin 16 17 pj:=fetionmsg; fHwnd:=FindWindow(nil,'短信中心'); 18 19 if fHwnd=0 then 20 21 begin showmessage('请先登录飞信2013短信中心'); exit; end; 22 23 if fHwnd>0 then begin 24 25 Postmessage(FindWindow(nil,'开班管理系统'),WM_DATA,1,2);{2-通知主窗体调整TOP} 26 27 // SendMessage(fHwnd,WM_SYSCOMMAND,SC_MAXIMIZE,0); //最大化 SC_MAXIMIZE SC_MINIMIZE //PostMessage(fHwnd,WM_SYSCOMMAND, SC_CLOSE,0); 28 29 cHwnd:=FindWindowEx(fHwnd,0,'FxRichEdit',nil); 30 31 if cHwnd>0 then 32 33 begin 34 35 sendmessage(cHwnd,messages.WM_LBUTTONDOWN ,0,$0180017A); {按下鼠标左键} 36 37 sendmessage(cHwnd,messages.WM_LBUTTONUP ,0, $0180017A); 38 39 {抬起鼠标左键} 40 41 SendMessage(cHwnd,WM_SETTEXT,0,0); {清空电话框} 42 43 for i := 1 to length(tel) do 44 45 SendMessage(cHwnd,WM_CHAR,Integer(tel[i]),0); 46 47 // SendMessage(cHwnd,WM_CHAR,Integer(#13),0); {回车} 48 49 SendMessage(chWnd, WM_KEYDOWN, VK_RETURN, 0); 50 51 SendMessage(chWnd, WM_KEYUP, VK_RETURN, 0); 52 53 end; 54 55 cHwnd1:=FindWindowEx(fHwnd,cHwnd,'FxRichEdit',nil); 56 57 cHwnd2:=FindWindowEx(fHwnd,cHwnd1,'FxRichEdit',nil); 58 59 cHwnd3:=FindWindowEx(fHwnd,cHwnd2,'FxRichEdit',nil); 60 61 if cHwnd1>0 then 62 63 begin 64 65 // showmessage('请先在上面的电话点击鼠标左键确定,再点ok'); 66 67 //MycloseWin; {2013-3-23去掉,可以不要点电话自动加信息} 68 69 SendMessage(cHwnd3,WM_SETTEXT,0,0); {清空信息框} 70 71 for i := 1 to length(pj) do 72 73 BEGIN 74 75 SendMessage(cHwnd3,WM_CHAR,Integer(pj[i]),0); 76 77 END; 78 79 end; 80 81 end; 82 83 end;