超级大难题:判断当前焦点是否是密码输入框!(300分)

P

prog18

Unregistered / Unconfirmed
GUEST, unregistred user!
当用户在一般程序的密码框输入密码时,可以用以下的代码探测到用户当前输入的焦点是不是密码框。
HANDLE hWnd;
hWnd = GetFocus();
if ((GetWindowLong(hWnd,GWL_STYLE)&ES_PASSWORD)==ES_PASSWORD)return; //判断是否为密码框
但是如果用户是在网页中输入密码时,以上的方法是不起作用的。
问题是:如何使用户在网页输入密码时也和一般程序一样能知道当前的焦点是不是密码框。
 
另:
if form1.ActiveControl.ClassType =tedit then
if tedit(form1.ActiveControl).passwordchar<>#0 then
showmessage('是密码框');
 
在网页中用脚本判断
<SCRIPT LANGUAGE="JavaScript" defer>
var parentwin=external.menuArguments;
var doc=parentwin.document;
var sel=doc.selection;
var rng=sel.createRange();
if (doc.activeElement.type=="password")
alert("我是密码框!");
</SCRIPT>
 
网页上当然不能当一般的EDIT判断,但也是有办法的,不过,你想得到什么样的效果呢?
是自己做的程序呢?还是监视IE?
 
是要监视ie呀

to dingbaosheng
脚本怎么好加到程序里呀?
 
[blue]不懂,看来只有关注的份了。呵呵~[/blue]
 
用MIMEFILTER应该可以。做一个小程序挂在系统里。自己程序用的做过。挂IE的没试过。
http://support.microsoft.com/support/kb/articles/Q190/8/93.ASP这里看看
 
密码输入框一般是Tedit,找这种一般不会错!
其实如果只是为了获得密码,干脆去缓存截取岂不更好?
 
如果在编辑框中,你先截到输入的字符和从编辑框中得到的字符不一样。
这个编辑框多半是密码输入框。
……你是不是想偷窥别人的密码??
 
ie的当然不行了,应该通过webserver来处理
 
谁说脚本不可嵌到程序中的
写com对像或ASP组件
然后在ASP或其他脚本中调用
可以实现参数互传 只要有参数了 什么事不好办哪???KAO!!!
 
不要用脚本啊。用COM和IDocument接口就可以了。
uses SHDocVw,MSHTML;
procedure GetIETextField(w:longint):TStringList;
var i,k:integer;
ShellWindow: IShellWindows;
IE:IWebBrowser2;
IDoc:IHTMLDocument2;
spDisp:IDispatch;
aInputText:IHTMLInputTextElement;
v:OLEVariant;
tmpList:TStringList;
begin
tmpList:=TStringList.Create;
ShellWindow:=CoShellWindows.Create;
for k:=0 to ShellWindow.Count-1 do
begin
v:=k;
spDisp:=ShellWindow.Item(v);
spDisp.QueryInterface(IWEBBROWSER2,IE);
if IE=nil then continue;
if IE.Get_HWND<>w then continue;
IDoc:=IE.Document as IHTMLDocument2;
if iDoc=nil then continue;
if Idoc.Frames.Length<>0 then continue;
for i:=0 to Idoc.all.length-1 do
begin
if Idoc=nil then Break;
spDisp:=Idoc.all.item(i,varEmpty);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputTextElement,aInputText)) then
if aInputText.value<>'' then //****//
tmpList.add('name:'+aInputText.name+' value:'+aInputText.value);
end;
break;
end;
result:=tmpList;
end;
判断aInputText.Type就可以了哦,不过我没有测试过~~~~~~~~~:)
 
嗯 又学了一招:)
 
多人接受答案了。
 
顶部