IE开启多个小号窗口并同时登录多个帐号
本帖最后由 逆水风帆 于 2014-12-2 23:39 编辑已经自行解决了,源码在11楼,期待论坛高手更好的办法啦!!
想达到打开多个IE浏览器窗口(即小号)并同时登录多个帐号,网站地址是:http://reg.fmmukq.com/passport/Index.aspx
登录部分的代码已经完成,但每次只能登录一个,除非打开小号窗口,否则无法多个账户同时登录。
自己尝试过_coproc()函数 以及 更改cookies的方法,也看过论坛里的多线程、多进程帖子,但是由于能力有限还是无法实现。
希望能够兼容IE各个版本吧!
登录部分的代码如下:;~ #include <CoProc.au3>
#include <ie.au3>
#include <Clipboard.au3>
#include <ScreenCapture.au3>
;修改注册表主要是不让IE弹出访问剪贴板的对话框
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", "1407", "REG_DWORD", "00000000")
login()
Sleep(2000)
Func login()
Local $j =1
;Local $cookiedir = "C:\Documents and Settings\cookie" & Chr(Random(97, 122, 1)) & @SEC & Random(1, 10000000) & Chr(Random(97, 122, 1)) & Chr(Random(65, 90, 1))
;RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Cookies", "REG_EXPAND_SZ", $cookiedir)
Local $gv_RandomCode = IniRead(@ScriptDir & "\UserData.ini", "User" & $j, "用户名", "")
Local $oIE = _IECreate("http://reg.fmmukq.com/passport/Index.aspx", 0, 1, 1, 0)
Local $oForm = _IEFormGetObjByName($oIE, "formLogin")
Local $oQuery = _IEFormElementGetObjByName($oForm, "selLoginType")
_IEFormElementOptionSelect($oQuery, "0", 1, "byValue")
$oQuery = _IEFormElementGetObjByName($oForm, "txtLoginName")
_IEFormElementSetValue($oQuery, $gv_RandomCode)
$oQuery = _IEFormElementGetObjByName($oForm, "txtLoginPwd")
_IEFormElementSetValue($oQuery, $gv_RandomCode)
Dim $i = 0
Local $oImgs = _IEImgGetCollection($oIE)
For $oImg In $oImgs
$i += 1
If $oImg.src = "http://reg.fmmukq.com/modules/verifyImage.ashx" Then
Local $oPic = $oIE.Document.body.createControlRange()
$oPic.Add($oImg)
$oPic.execCommand("Copy")
Local $img = ClipGet()
_ClipBoard_Open(0)
Local $hMemory = _ClipBoard_GetDataEx($CF_BITMAP)
_ClipBoard_Close()
FileDelete(@ScriptDir & "\verifypic1.bmp")
_ScreenCapture_SaveImage(@ScriptDir & "\verifypic1.bmp", $hMemory)
EndIf
Next
Local $AntiDll = DllOpen("AntiVC.dll") ;识别的dll路径
Local $LocalCDS = @ScriptDir & "\fmmukq.cds";识别库的路径
Local $index = DllCall($AntiDll, "long", "LoadCdsFromFile", "str", $LocalCDS)
If $index = -1 Then
MsgBox(0, "错误", "识别库不存在或者打不开")
Exit
EndIf
Local $CdsResult = DllCall($AntiDll, "int", "GetVcodeFromFile", "int", $index, "str", @ScriptDir & "\verifypic1.bmp", "str", 0)
If $CdsResult = -1 Then
MsgBox(0, "错误", "识别验证码失败")
Exit
EndIf
DllClose($AntiDll)
$oQuery = _IEFormElementGetObjByName($oForm, "txtCheckCode")
_IEFormElementSetValue($oQuery, $CdsResult)
$oIE.document.parentWindow.execscript("Passport.doLogin()")
Sleep(3000)
Local $Ele = _IETagNameGetCollection($oIE, "DIV", 2)
If $Ele <> 0 And StringInStr($Ele.innertext, "欢迎来到口腔医院预约挂号网") Then
_IENavigate($oIE, "http://reg.fmmukq.com/Doctor/Index.aspx?id=6101002010223010")
Exit
EndIf
EndFunc ;==>login
需要调用的识别码库文件以及已经生成的测试账户在附件(如果需要收费请联系我,我上传到网盘): 自己顶一下,希望不要沉了! 还请各位高手不吝赐教呢{:face (88):} 自己顶一下 也碰到这样的问题,求解啊 回复 5# nqawen
是啊?看来还是挺多人需要的哈! 问题已自行解决,关闭啦 能否分享一下解决方法 发一下源码 回复 9# jkq920
应该可以这样尝试:
用窗体内嵌IE控件方法,一个帐号建立一个窗体. Local $sURL = "http://reg.fmmukq.com/passport/Index.aspx"
Local $pid = Run(@ProgramFilesDir & "\internet explorer\iexplore.exe -noframemerging -sessionmerging " & $sURL, "", @SW_SHOW)
Sleep(5000)
Local $hHandle = _ProcessGetHWnd($pid)
Local $oIE = _IEAttach($hHandle, "HWND")
While IsObj($oIE) = 0
$hHandle = _ProcessGetHWnd($pid)
$oIE = _IEAttach($hHandle,"HWND")
WEnd
Local $oForm = _IEFormGetObjByName($oIE, "formLogin")
Local $oQuery = _IEFormElementGetObjByName($oForm, "selLoginType")
_IEFormElementOptionSelect($oQuery, "0", 1, "byValue")
Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000)
Local $aReturn = [], $aWin, $hTimer = TimerInit()
While 1
$aWin = WinList($sTitle)
For $i = 1 To $aWin
$iPid = WinGetProcess($aWin[$i])
If $iPid Then
If $iOption = 1 Or ($iOption = 0 And $aWin[$i] <> "") Then
Return $aWin[$i]
ElseIf $iOption = 2 Then
ReDim $aReturn
$aReturn += 1
$aReturn[$aReturn] = $aWin[$i]
$aReturn[$aReturn] = $aWin[$i]
EndIf
EndIf
Next
If $iOption = 2 And $aReturn > 0 Then Return $aReturn
If TimerDiff($hTimer) > $iTimeout Then ExitLoop
Sleep(Opt("WinWaitDelay"))
WEnd
SetError(1)
Return 0
EndFunc ;==>_ProcessGetHWnd上面的_ProcessGetHWnd是借鉴论坛一高手的,要求是IE浏览器必须为版本8及以上,然后通过IE浏览器的新建会话功能的命令行运行IE小号窗口,然后将IE窗口的进程PID转换为窗口句柄,然后就可以进行常规操作了! 回复 8# jkq920
源码在11楼呢 回复 9# jkq920
源码在11楼呢 前来学习。。。。。。。。。。。。。。。 没法修改窗口标题哈,关闭了哈
页:
[1]