C
creation-zy
Unregistered / Unconfirmed
GUEST, unregistred user!
如题,我的主要目的是要写一个 Single Sign On (单点登陆)工具,它必须能够探测到窗体/IE页面<br>中的密码输入框,并且实现模拟输入用户名/密码+按下“确定”按钮的功能。<br><br> 我现在实现了一个最基本过程,它能获得当前窗口句柄以及得到焦点的控件的部分信息:<br><br>var<br> LastFocusH:HWnd=0;<br>procedure CheckPwdWindow;<br>var<br> FocusH,WindowH,ChildH:HWnd;<br> ThreadH:dword;<br> Buf:array[0..1024]of Char;<br> Style:Integer;<br> Str:String;<br> procedure ShowCtrlInfo(H:HWnd);<br> begin<br> FillChar(Buf,1024,0);<br> SendMessage(H,WM_GETTEXT,1024,Integer(@Buf[0]));<br> Form1.Memo1.Lines.Add('内容: '+String(Buf));<br> FillChar(Buf,1024,0);<br> GetClassName(FocusH,@Buf[0],1024);<br> Form1.Memo1.Lines.Add('Class: '+String(Buf)+#13#10);<br> FillChar(Buf,1024,0);<br> Style:=GetWindowLong(H,GWL_STYLE);<br> Str:='Style: '+IntToHex(Style,8)+#13#10;<br> if Style and ES_NUMBER>0 then<br> Str:=Str+' ES_NUMBER';<br> if Style and ES_PASSWORD>0 then<br> Str:=Str+' ES_PASSWORD';<br> if Style and ES_MULTILINE>0 then<br> Str:=Str+' ES_MULTILINE';<br> if Style and ES_READONLY>0 then<br> Str:=Str+' ES_READONLY';<br> Form1.Memo1.Lines.Add(Str);<br> end;<br>begin<br> WindowH:=GetForegroundWindow;<br> if WindowH=Form1.Handle then<br> exit;<br> ThreadH:=GetWindowThreadProcessId(WindowH,nil);<br> AttachThreadInput(GetCurrentThreadId,ThreadH,true);<br> FocusH:=GetFocus;<br> if FocusH=LastFocusH then<br> exit<br> else<br> LastFocusH:=FocusH;<br> AttachThreadInput(GetCurrentThreadId,ThreadH,false);<br> if FocusH=0 then<br> Exit;<br> FillChar(Buf,1024,0);<br> SendMessage(WindowH,WM_GETTEXT,1024,Integer(@Buf[0]));<br> Form1.Memo1.Lines.Add('标题: '+String(Buf));<br> ShowCtrlInfo(FocusH);<br>end;<br><br> 但是在使用中发现,它不能获得IE页面内部的控件Handle。请高手指点!<br> 还有一个问题就是如何获得窗体的全部子控件?<br><br> 请大家帮忙提前,谢谢!!