Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WinAPI.au3>
- #include <GUIConstantsEx.au3>
- #include <IE.au3>
- #include <WindowsConstants.au3>
- MsgBox(0,'Result',RecaptchaBox("woobox.com/wijcoc/hesk5h?embed=1"))
- #cs
- Hàm RecaptchaBox($url,$theme,$bgcolor,$lang)
- ------------- param -------------
- $url: địa chỉ trang có recaptcha vd: https://www.google.com/recaptcha/api2/demo
- $theme: dark hoặc light, mặc định là light
- $bgcolor: cái này tích hợp vào gui mới cần
- $lang: ngôn ngữ mặc định là Việt Nam
- -------------- return -------------
- Trả về gcaptcha-response dùng để request
- #ce
- Func RecaptchaBox($url,$theme='light',$bgcolor='#FFFFFF',$lang='vi')
- Local $oIE = _IECreateEmbedded()
- $gui = GUICreate("Recaptcha box", 330, 94,(@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2)
- $ojb = GUICtrlCreateObj($oIE, 0, 0, 330, 510)
- GUICtrlSetResizing(-1, 544/2)
- GUISetBkColor(0xFFFFFF)
- _IENavigate($oIE, $url)
- $DataSiteKey = StringRegExp(_IEBodyReadHTML($oIE),'https:.*?k=(.*?)&',1); regex sida
- If @error Then
- GUIDelete()
- Return 'error: can not find recaptcha in site'
- endif
- $oIE.document.parentwindow.execScript("document.write('<body></body>');var iDiv = document.createElement('div');iDiv.id = 'recaptchaa';document.getElementsByTagName('body')[0].appendChild(iDiv);var jq = document.createElement('script');jq.src = 'https://www.google.com/recaptcha/api.js';document.getElementsByTagName('head')[0].appendChild(jq);")
- $oIE.document.parentwindow.execScript("captcha = grecaptcha.render(document.getElementById('recaptchaa'), {'sitekey' : '"& $DataSiteKey[0] &"','theme':'"&$theme&"','hl' : '"&$lang&"'});")
- $oIE.document.parentwindow.execScript("document.body.style.background = '"& $bgcolor &"';")
- $RecaptchaResponse = $oIE.document.parentwindow.eval('grecaptcha.getResponse(captcha);')
- GUISetState(@SW_SHOW) ;Show GUI
- Do
- Sleep(10)
- Until MemoryReadPixel(268, 49, $gui) = '0x4F8EF5' ; chờ load captcha trên Gui
- Do
- Sleep(10)
- Until MemoryReadPixel(26, 113, $gui) <> '0xFFFFFF' ;nếu click
- WinMove($gui,'',Default,Default,Default,540)
- While $oIE.document.parentwindow.eval('grecaptcha.getResponse(captcha);') = '' ;loop cho tới khi giải captcha thành công
- Local $iMsg = GUIGetMsg()
- Switch $iMsg
- Case $GUI_EVENT_CLOSE
- ExitLoop
- EndSwitch
- Sleep(100)
- WEnd
- $RecaptchaResponse = $oIE.document.parentwindow.eval('grecaptcha.getResponse(captcha);')
- If $RecaptchaResponse <> '' Then
- WinMove($gui,'',Default,Default,Default,94+30)
- GUIDelete()
- Return $RecaptchaResponse
- endif
- GUIDelete()
- Return False
- EndFunc
- Func MemoryReadPixel($x, $y, $handle)
- Local $hDC
- Local $iColor
- Local $sColor
- $hDC = _WinAPI_GetWindowDC($handle)
- $iColor = DllCall("gdi32.dll", "int", "GetPixel", "int", $hDC, "int", $x, "int", $y)
- $sColor = Hex($iColor[0], 6)
- _WinAPI_ReleaseDC($handle, $hDC)
- Return "0x" & StringRight($sColor, 2) & StringMid($sColor, 3, 2) & StringLeft($sColor, 2)
- EndFunc ;==>MemoryReadPixel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement