如何得到当前拨号连接窗口中的电话号码或该窗口中的指定控件的值?(100分)

  • 主题发起人 主题发起人 williem
  • 开始时间 开始时间
W

williem

Unregistered / Unconfirmed
GUEST, unregistred user!
目的:了解如何在自己的程序中获得外部某个活动的窗口中指定的控件的值?如打开了拨号<br>&nbsp; &nbsp; &nbsp; 连接窗口中的电话号码?<br>我已做的:<br>//查询指定窗口的句柄<br>Function EnumWindowsProc(hWindow:hWnd;lParam:LongInt):Bool<br>{$IFDEF Win32} Stdcall;{$ELSE};Export;{$ENDIF}<br>var<br>lpBuffer:PChar;<br>WindowCaptionFound:Bool;<br>ClassNameFound:Bool;<br>begin<br>&nbsp;GetMem(lpBuffer,255);<br>&nbsp;Result:=True;<br>&nbsp;WindowCaptionFound:=False;<br>&nbsp;ClassNameFound:=False;<br>&nbsp;try<br>&nbsp; &nbsp;if GetWindowText(hWindow,lpBuffer,255)&gt;0 then<br>&nbsp; &nbsp; &nbsp; if Pos(PFindWindowStruct(lParam).Caption,StrPas(lpBuffer))&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WindowCaptionFound:=True;<br>&nbsp; &nbsp;if PFindWindowStruct(lParam).ClassName='' then<br>&nbsp; &nbsp; &nbsp; ClassNameFound:=True<br>&nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; if GetClassName(hwindow,lpBuffer,255) &gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Pos(PFindWindowStruct(lParam).ClassName,StrPas(lpBuffer))&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ClassNameFound:=True;<br>&nbsp; &nbsp;if (WindowCaptionFound and ClassNameFound) then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; PFindWindowStruct(lParam).WindowHandle:=hWindow;<br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=False;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp;Finally<br>&nbsp; &nbsp; &nbsp;FreeMem(lpBuffer,SizeOf(lpBuffer^));<br>&nbsp; &nbsp;end;<br>end;<br>——————————————————————————————————————<br>//查询指定的窗口<br>Function FindAWindow(Caption:String;ClassName:String):THandle;<br>var<br>WinInfo:TFindWindowStruct;<br>begin<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; WinInfo.Caption:=Caption;<br>&nbsp; &nbsp; &nbsp; WinInfo.ClassName:=ClassName;<br>&nbsp; &nbsp; &nbsp; WinInfo.WindowHandle :=0;<br>&nbsp; &nbsp; &nbsp; EnumWindows(@EnumWindowsProc,LongInt(@WinInfo));<br>&nbsp; &nbsp; &nbsp; FindAWindow:=WinInfo.WindowHandle;<br>&nbsp; &nbsp;end;<br>end;<br>——————————————————————————————————————<br>//得到指定窗口的各个控件的类和值,但不知道如何查找指定其中某个类的值<br>Function EnumChildProc(hWnd:integer;lParam:LongInt):Bool<br>{$IFDEF Win32} Stdcall;{$ELSE};Export;{$ENDIF}<br>var<br>Clsname,Caption:Array[0..60] of Char;<br>ff:string;<br>star:integer;<br>begin<br>&nbsp; GetClassName(hWnd,ClsName,60);<br>&nbsp; GetWindowText(hWnd,Caption,60);<br>&nbsp; Form1.Memo1.Lines.Add('类名'+ClsName+'值:'+Caption);<br>&nbsp;For star:=0 to Form1.ComboBox1.Items.Count do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ff:=Form1.ComboBox1.Items[star];<br>&nbsp; &nbsp; &nbsp; if (ClsName='Static') and (Caption=ff) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Form1.Button1.Caption:='169';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result:=True<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; end;<br>end;<br>问题:我已经可以截获指定标题的外部程序的窗口了,但不知如何查询该窗口中指定的控件的值?<br>&nbsp; &nbsp; &nbsp; 也就是如何修改EnumChildProc已使他能实现这一功能??
 
也可以这样想:如何得到当前用户要拨的电话号码?
 
想法比较无聊。
 
sorry<br>不熟悉
 
一个过客,讲讲你是如何理解的?
 
我根本就不会去关心“当前用户要拨的电话号码”,因为这属于个人隐私。
 
你理解错了,我想知道譬如在线计费程序就要通过知道用户拨的号码来自动计算相应的网费啊
 
那你还不如屏蔽掉用户原来的拨号网络功能,自己写一个拨号上网程序,不久什么都解决了。<br>你的思维太怪异。
 
各位,我是原来是设想通过截取当前活动的windows拨号窗口而后得到其中有关电话号码的控件的值<br>但好象我的函数达不到效果,我手头的资料少,请帮忙想一下.写了
 
听我说的没错。<br>既然用户能够容忍你的程序截获她的电话号码,那你还不如干脆写一个拨号上网程序的了。
 
为什么怪异?用户用惯了windows的拨号方式,所以我设想我的上网计费程序只要截获所拨的<br>ISP号码,就自动进行相应的网费计算,这又什么怪的?
 
因为你的想法属于旁门左道,不正统。正规软件没有这么做的。<br><br>〉〉用户用惯了windows的拨号方式<br>你的程序完全可以做的跟windows自己的拨号程序一样啊
 
好吧,那我换个问法,有没有方法调用外部程序指定窗口中的指定控件值?调用外部程序窗口中的值好象不是旁门左道吧!<br>如果你的程序要别的程序中的值你难道要写一个和他一样的程序吗?<br>口气有点过你海量了.
 
恕我直言,确实是旁门左道。没见过正经公司的软件这么搞的。<br>你的思维不适合写程序。<br><br>再见,睡觉去了!
 
一个过客就是过客,回答问题也是象"过客".用这种方法编程看来你编程序一定很辛苦!<br>算了,也许你根本就没理解我的问题,因为你太累了.睡吧好好休息,换换脑子吧
 
哈哈,正有你的"卷起千堆雪tyn",有人还自称高手,看见问题就回避还美其名曰"歪门邪道",<br>看看上面的帖子这才是真正的高手!
 
可惜点少了些对不住啊
 
不会!!!!!!!!!!!!!
 
&nbsp; &nbsp; &nbsp; &nbsp;~~~彻底搞定~~~<br><br>&nbsp;private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; &nbsp; procedure GetMousePosHwndAndClassName(Sender : TPoint);<br><br>procedure TForm1.GetMousePosHwndAndClassName(Sender: TPoint);<br>var<br>&nbsp; hWnd: THandle;<br>&nbsp; aName: array [0..255] of char;<br>begin<br>&nbsp; hWnd := WindowFromPoint(Sender);<br>&nbsp; Label1.Caption := 'Handle : ' + IntToStr(hWnd);<br>&nbsp; if boolean(GetClassName(hWnd, aName, 256)) then<br>&nbsp; &nbsp; Label2.Caption := 'ClassName : ' + string(aName)<br>&nbsp; else<br>&nbsp; &nbsp; Label2.Caption := 'ClassName : not found';<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; Form1.FormStyle := fsStayOnTop;<br>&nbsp; Timer1.Interval := 50;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>&nbsp; rPos: TPoint;<br>begin<br>&nbsp; if boolean(GetCursorPos(rPos)) then<br>&nbsp; &nbsp; GetMousePosHwndAndClassName(rPos);<br>end;
 

Similar threads

后退
顶部