找回密码
 加入
搜索
查看: 4231|回复: 13

为什么不能自动填IE上的表单啊

[复制链接]
发表于 2008-12-27 12:47:36 | 显示全部楼层 |阅读模式
郁闷!我在网上抄来的代码在我的电脑上也不能成功
#include <IE.au3>
$oIE = _IECreate ("http://mail.163.com",0,0,1,0)
_IEPropertySet ($oIE, "toolbar", 0)
_IEPropertySet ($oIE, "width", 600)
_IEPropertySet ($oIE, "height", 600)
_IEPropertySet ($oIE, "resizable", 0)
$oForm = _IEFormGetObjByName ($oIE, "login163")
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery = _IEFormElementGetObjByName ($oForm, "password")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery = _IEFormElementGetObjByName ($oForm, "selType")
_IEFormElementOptionSelect ($oQuery , 1, 1, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 0, "", 0, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 1, "", 0, "byIndex")
$oQuery = _IEFormElementGetObjByName ($oForm, "登录邮箱")
_IEAction($oQuery ,"click")
sleep(2000)
_IEAction ($oIE, "visible")
只能打开网页 不能在那个login163表单里写进字
#include <IE.au3>
$oIE = _IECreate ("www.baidu.com")
$oForms = _IEFormGetCollection ($oIE)
$file = FileOpen("新建文本文档.txt",1)
FileWrite($file,"这个页面上共有" & @extended & "个表单")
For $Form In $oForms
FileWrite($file,$Form.name)
$oQuerys = _IEFormElementGetCollection ($Form)
For $Query In $oQuerys
FileWrite($file,"名称:"&$Query.name & " 类型:"&$Query.type)
Next
Next
上面这段查询表单的代码也只能打开网页 MSGBOX也不能出现 只会弹出一个空网页(不是前面的那个网页)
心烦啊 为什么啊 我一模一样抄也不能成功 我用的是VISTA的IE7 有没有关系的啊

[ 本帖最后由 luckscy 于 2008-12-29 22:13 编辑 ]
发表于 2008-12-27 13:50:18 | 显示全部楼层
难道登录邮箱一定要用软件吗?就不能用更直接的办法吗?
你把网站的原代码复制出来,直接在表单中先填好名字和密码
保存为网页,不是很省事吗?
<html> 
<head>
<title>登录163</title> 
</head> 
<body onload="document.form1.submit()"> 
正在登录到邮箱... 
<form name="form1" action="http://reg.163.com/login.jsp?type=1&url=http://fm163.163.com/coremail/fcg/ntesdoor2?lightweight%3D1%26verifycookie%3D0%26language%3D-1%26style%3D-1" method="post">


<input type="hidden" name="username" value="邮箱"> 
<input type="hidden" name="password" value="密码">


</form> 
</body> 
</html>
发表于 2008-12-27 13:52:33 | 显示全部楼层
不过你那个VISTA我不知道能不能登,反正我的能登..打开一下上面那条黄带

[ 本帖最后由 xinda 于 2008-12-27 14:18 编辑 ]
发表于 2008-12-27 15:01:50 | 显示全部楼层
帮助也没看一下,抄也是不会的!代码中完全没有MSGBOX,何来MSGBOX的出现!?
 楼主| 发表于 2008-12-27 23:13:29 | 显示全部楼层
#include <IE.au3>
$oIE = _IECreate ("http://mail.163.com")
$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "表单信息", "这个页面上共有" & @extended & "个表单")
For $Form In $oForms
MsgBox(0, "表单名称", $Form.name)
$oQuerys = _IEFormElementGetCollection ($Form)
For $Query In $oQuerys
MsgBox(0, "表单控件信息", "名称:"&$Query.name & " 类型:"&$Query.type)
Next
Next
不好意思 第二段代码抄错了 就是这段 MSGBOX没有出现 只出现了空白网页
我是为了学习IE UDF才弄着个 所以我一定要写这些软件 牛人们帮帮我
还有我发现网上关于AUTOIT的资料实在有点少啊 哎
发表于 2008-12-28 20:21:22 | 显示全部楼层
出现空白网页是不会出现MSGBOX的(应该说只会出现一个MSGBOX,如果连那也没出现,那就...),检查为什么出现空白页是关键,这段代码正确的很

[ 本帖最后由 liongodmien 于 2008-12-28 20:23 编辑 ]
发表于 2008-12-28 22:38:56 | 显示全部楼层
源码一大抄,要学会抄源码。。。~_~
 楼主| 发表于 2008-12-29 12:15:56 | 显示全部楼层
五楼的那段代码能打开http://mail.163.com这个网页 但就是不出MSGBOX 只出空白网页 实在想不通啊 SCITE能不能看这个过程中的哪句话中出了那个空白的页啊
 楼主| 发表于 2008-12-29 12:22:06 | 显示全部楼层
我日 一模一样的代码我朋友的XP上面一切OK 有没有高人给我个办法 我不想换系统啊
发表于 2008-12-29 14:36:11 | 显示全部楼层
试:
#RequireAdmin
--------------------------------------------------------------------------------

需要管理员用户才能执行脚本.


#RequireAdmin




参数

没有.



注意

这个函数主要针对 AutoIt 脚本运行于 Windows Vista User Account Control (UAC)下面. (因此,同样可以运行于 Windows 2000 和 Windows XP).

更多信息请参考  AutoIt on Windows Vista.
 楼主| 发表于 2008-12-29 17:29:40 | 显示全部楼层
感谢楼上高人指点
加了#RequireAdmin之后
_IEPropertySet ($oIE, "toolbar", 0)
_IEPropertySet ($oIE, "width", 600)
_IEPropertySet ($oIE, "height", 600)
_IEPropertySet ($oIE, "resizable", 0)
这些代码能起作用 原来这些代码也没有起作用
#include <IE.au3>
$oIE = _IECreate ("http://mail.163.com")
$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "表单信息", "这个页面上共有" & @extended & "个表单")
For $Form In $oForms
MsgBox(0, "表单名称", $Form.name)
$oQuerys = _IEFormElementGetCollection ($Form)
For $Query In $oQuerys
MsgBox(0, "表单控件信息", "名称:"&$Query.name & " 类型:"&$Query.type)
Next
Next
这段代码完全起作用 好高兴
但是写进表单的这段代码 也就是下面这段代码
$oForm = _IEFormGetObjByName ($oIE, "login163")
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery = _IEFormElementGetObjByName ($oForm, "password")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery = _IEFormElementGetObjByName ($oForm, "selType")
_IEFormElementOptionSelect ($oQuery , 1, 1, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 0, "", 0, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 1, "", 0, "byIndex")
$oQuery = _IEFormElementGetObjByName ($oForm, "登录邮箱")
_IEAction($oQuery ,"click")
sleep(2000)
_IEAction ($oIE, "visible")
依旧不起作用
还有liongodmien 我想问你下那个AutoIt on Windows Vista.是哪儿有的啊 好像帮助里找不到啊
发表于 2008-12-29 21:34:12 | 显示全部楼层

回复 11# luckscy 的帖子

呵呵,我上面那回复是完全从帮助里复制出来的

上面的代码是可以的

#RequireAdmin
#include <IE.au3>
$oIE = _IECreate ("http://mail.163.com")
$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "表单信息", "这个页面上共有" & @extended & "个表单") 
For $Form In $oForms
MsgBox(0, "表单名称", $Form.name)
$oQuerys = _IEFormElementGetCollection ($Form)
For $Query In $oQuerys
MsgBox(0, "表单控件信息", "名称:"&$Query.name & " 类型:"&$Query.type)
Next
Next
$oForm = _IEFormGetObjByName ($oIE, "login163")
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery = _IEFormElementGetObjByName ($oForm, "password")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery = _IEFormElementGetObjByName ($oForm, "selType")
_IEFormElementOptionSelect ($oQuery , 1, 1, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 0, "", 0, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 1, "", 0, "byIndex") 
$oQuery = _IEFormElementGetObjByName ($oForm, "登录邮箱")
_IEAction($oQuery ,"click")
sleep(2000)
_IEAction ($oIE, "visible") 
 楼主| 发表于 2008-12-29 22:12:43 | 显示全部楼层
太感谢liongodmien同志了 行了
 楼主| 发表于 2008-12-29 22:40:05 | 显示全部楼层
填表单真是件麻烦的事 查询表单的程序查出来的表单是不是不一定正确的啊 本人HTML不太熟 有没有高人有好点的表单查询的代码
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 05:43 , Processed in 0.076697 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表