找回密码
 加入
搜索
查看: 14673|回复: 14

[IE类操作] IE开启多个小号窗口并同时登录多个帐号

  [复制链接]
发表于 2014-11-28 18:26:29 | 显示全部楼层 |阅读模式
悬赏88金钱未解决
本帖最后由 逆水风帆 于 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[0] = -1 Then
                MsgBox(0, "错误", "识别库不存在或者打不开")
                Exit
        EndIf
        Local $CdsResult = DllCall($AntiDll, "int", "GetVcodeFromFile", "int", $index[0], "str", @ScriptDir & "\verifypic1.bmp", "str", 0)
        If $CdsResult[0] = -1 Then
                MsgBox(0, "错误", "识别验证码失败")
                Exit
        EndIf
        DllClose($AntiDll)
        $oQuery = _IEFormElementGetObjByName($oForm, "txtCheckCode")
        _IEFormElementSetValue($oQuery, $CdsResult[3])
        $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
需要调用的识别码库文件以及已经生成的测试账户在附件(如果需要收费请联系我,我上传到网盘):

附件: 您需要 登录 才可以下载或查看,没有账号?加入
 楼主| 发表于 2014-11-28 18:33:56 | 显示全部楼层
自己顶一下,希望不要沉了!
 楼主| 发表于 2014-11-28 18:37:19 | 显示全部楼层
还请各位高手不吝赐教呢
 楼主| 发表于 2014-11-29 08:23:30 | 显示全部楼层
自己顶一下
发表于 2014-11-29 09:41:41 | 显示全部楼层
也碰到这样的问题,求解啊
 楼主| 发表于 2014-11-29 11:51:41 | 显示全部楼层
回复 5# nqawen


    是啊?看来还是挺多人需要的哈!
 楼主| 发表于 2014-11-30 00:44:27 | 显示全部楼层
问题已自行解决,关闭啦
发表于 2014-11-30 02:37:18 | 显示全部楼层
能否分享一下解决方法
发表于 2014-11-30 02:37:55 | 显示全部楼层
发一下源码
发表于 2014-11-30 11:19:24 | 显示全部楼层
回复 9# jkq920

应该可以这样尝试:
    用窗体内嵌IE控件方法,一个帐号建立一个窗体.
 楼主| 发表于 2014-12-2 23:35:34 | 显示全部楼层
        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[1][1] = [[0]], $aWin, $hTimer = TimerInit()
        While 1
                $aWin = WinList($sTitle)
                For $i = 1 To $aWin[0][0]
                        $iPid = WinGetProcess($aWin[$i][1])
                        If $iPid Then
                                If $iOption = 1 Or ($iOption = 0 And $aWin[$i][0] <> "") Then
                                        Return $aWin[$i][1]
                                ElseIf $iOption = 2 Then
                                        ReDim $aReturn[UBound($aReturn) + 1][2]
                                        $aReturn[0][0] += 1
                                        $aReturn[$aReturn[0][0]][0] = $aWin[$i][0]
                                        $aReturn[$aReturn[0][0]][1] = $aWin[$i][1]
                                EndIf
                        EndIf
                Next
                If $iOption = 2 And $aReturn[0][0] > 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转换为窗口句柄,然后就可以进行常规操作了!
 楼主| 发表于 2014-12-2 23:36:55 | 显示全部楼层
回复 8# jkq920


    源码在11楼呢
 楼主| 发表于 2014-12-2 23:37:20 | 显示全部楼层
回复 9# jkq920


    源码在11楼呢
发表于 2014-12-5 09:14:30 | 显示全部楼层
前来学习。。。。。。。。。。。。。。。
 楼主| 发表于 2014-12-7 17:14:39 | 显示全部楼层
没法修改窗口标题哈,关闭了哈
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-30 02:06 , Processed in 0.085297 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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