|
需要将本地磁盘的某个图片文件作为本站头像,这样的脚本怎么写?我写了这样的一个函数,文件上传的对话框是打开了,接下来的问题不好弄了,求解,代码如下:
Call QTPFuns("testing","0.1230")'连接地址http://www.qtpfuns.com/read.php?tid=524
Function QTPFuns(Uname,Upsd)
SystemUtil.CloseProcessByName"iexplore.exe"
SystemUtil.Run"iexplore.exe"
Set brs=Description.Create()
brs("name").Value=".*"
Set pg=Description.Create()
pg("name").Value=".*"
Set CurPage=Browser(brs).Page(pg)
CurPage.Sync
Set upface=CurPage.WinObject("nativeclass:=.*")
Browser(brs).Navigate "http://www.qtpfuns.com/profile.php"
CurPage.WebEdit("name:=pwuser").Set Uname
CurPage.WebEdit("name:=pwpwd").Set Upsd
CurPage.WebButton("name:=登录").Click
CurPage.Link("name:=修改头像").Click
CurPage.WinObject("nativeclass:=MacromediaFlashPlayerActiveX").Click
btn_x=CurPage.WinObject("nativeclass:=MacromediaFlashPlayerActiveX").GetROProperty("abs_x")+10
btn_y=CurPage.WinObject("nativeclass:=MacromediaFlashPlayerActiveX").GetROProperty("abs_y")+20
Extern.Declare micInteger,"SetCursorPos","User32.dll","",micInteger,micInteger
Extern.SetCursorPos btn_x,btn_y
Extern.Declare micVoid, "mouse_event", "User32.dll", "mouse_event", micByte,micByte,micDWord,micULong
Extern.mouse_event 2,0,0,0
Extern.mouse_event 4,0,0,0
End Function
观察这个打开的对话框可以发现,焦点正好在要输入的文件名处,这样可以使用SendKeys一个一个输,或者FindWindow再SetWindowText,有没有其他办法解决? 我需要实现一个这样的函数,传入用户名、密码、图片地址即可完成换头像功能(不必要调整) |
|