怎么后台点击百度网盘分享页面的多选框?
本帖最后由 Mixrelax 于 2019-5-21 20:49 编辑#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
Opt("TrayIconDebug", 1) ;Debug时专用
HotKeySet("{`}", "_Exit") ;一键退出
Local $oIE = _IECreateEmbedded()
GUICreate("Embedded Web control Test", 640, 580, _
(@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
$WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 40, 600, 360)
Local $idButton_Download = GUICtrlCreateButton("下载", 10, 420, 100, 30)
Global $g_idError_Message = GUICtrlCreateLabel("", 100, 500, 500, 30)
GUICtrlSetColor(-1, 0xff0000)
;~ 链接:https://pan.baidu.com/s/10pDYoU9E7pOLbxpjmF4AgA
;~ 提取码:vak4文件夹
;~ 复制这段内容后打开百度网盘手机App,操作更方便哦
GUISetState(@SW_SHOW)
_IENavigate($oIE, "https://pan.baidu.com/s/10pDYoU9E7pOLbxpjmF4AgA") ;文件夹
_IEAction($oIE, "stop")
Func _Exit()
Exit
EndFunc ;==>_Exit
While 1
Local $iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
ExitLoop
Case $iMsg = $idButton_Download
;请问仁兄,这里怎么写? 多谢!
EndSelect
WEnd
这个函数 _IEFormElementCheckBoxSelect ,试了不可以的。
本帖最后由 Mixrelax 于 2019-5-24 00:10 编辑
#NoTrayIcon
#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $src_img, $src_HTML, $oItem, $id = 0
Local $oIE = _IECreateEmbedded()
$hGui = GUICreate("Embedded Web control Test", 640, 580, _
(@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
$WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_SetState")
While 1
$str = ClipGet()
$Code = StringRegExpReplace($str, '(?ims).*?提取码:(\w{4}).*?[\s\n]+?复制.*', '$1')
$Link = StringRegExpReplace($str, '(?ims).*?链接:.*(https:)(.*?)[\s\n\W]+?提取码.*', '$1$2')
If StringInStr($Link, 'https://pan.baidu.com/s') And StringLen($Code) = 4 Then AutoExits_Download()
WEnd
Func GUI_SetState()
GUISetState(@SW_HIDE, $hGui)
EndFunc ;==>GUI_SetState
Func AutoExits_Download()
ClipPut('')
MsgBox(64 + 262144, "提示", "您已复制提取码。3 秒后将开始下载!", 1)
GUICtrlCreateObj($oIE, 10, 40, 600, 360)
_IENavigate($oIE, $Link) ;文件夹
Local $oForm = _IEFormGetObjByName($oIE, "accessForm")
$ele_Input = _IEFormElementGetObjByName($oForm, "rrxevJ5B")
_IEFormElementSetValue($ele_Input, $Code)
_IELinkClickByText($ele_Input, "提取文件")
Do
$BodyText = $oIE.document.body.innerHTML
Until StringInStr($BodyText, "下载") ;读取网页body部份的HTML,直到含有给的代码
$Match = StringRegExp($BodyText, '(?U)span.*>(下载.*)</span>.*', 1)
If $Match <> 0 Then
If $Match <> '下载' Then
_IELinkClickByText($oIE, $Match)
AdlibRegister('CheckError',500)
$id = 1
Else
Local $oItems = _IETagNameGetCollection($oIE, "span")
For $oItem In $oItems
_IEAction($oItem, 'click')
$src = _IEDocReadHTML($oItem)
If StringInStr($src, "EzubGg") Then
_IELinkClickByText($oIE, $Match)
AdlibRegister('CheckError',500)
ExitLoop
EndIf
Next
EndIf
EndIf
EndFunc ;==>AutoExits_Download
Func CheckError()
$src_HTML = _IEDocReadHTML($oIE)
If StringInStr($src_HTML, "请输入验证码") Then
AdlibUnRegister('CheckError')
MsgBox(64 + 262144, "提示", "本次下载需要手动输入验证码!")
GUISetState(@SW_SHOW, $hGui)
$id = 1
ElseIf StringInStr($src_HTML, "请点击下载") Then
AdlibUnRegister('CheckError')
_IELinkClickByText($oIE, '立即下载')
$hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
While 1
If WinExists('文件下载', '你要打开还是保存此文件?') Or TimerDiff($hTimer) > 1000 * 5 Then
WinSetOnTop('文件下载', '你要打开还是保存此文件?', 1)
$id = 1
ExitLoop
EndIf
Sleep(250)
WEnd
EndIf
If WinExists('设置下载存储路径') Then
AdlibUnRegister('CheckError')
$id = 1
EndIf
EndFunc ;==>CheckError
页:
[1]