blackandwhite

Login, Post news and Logout in IE

9 posts in this topic

Hello everybody!

need to join these codes into one:

#include <IE.au3>

$sLogin = 'login@mail.com'
$sPass = 'password'
$sUrl = "m.facebook.com"

$oIE = _IECreate($sUrl)
$hWnd = _IEPropertyGet($oIE, "hwnd")
WinSetState($hWnd, "", @SW_MAXIMIZE)

$oLogin = _IEGetObjByName($oIE, 'email')
$oPass = _IEGetObjByName($oIE, 'pass')
_IEFormElementSetValue($oLogin, $sLogin)
_IEFormElementSetValue($oPass, $sPass)
$oButton = _IEGetObjByName($oIE, 'login')
_IEAction($oButton, 'click')
_IEAttach("Facebook")
_IENavigate($oIE, "https://m.facebook.com/groups/1/") ;1

$oPost3 = _IEGetObjByName($oIE, 'xc_message')
_IEFormElementSetValue($oPost3, 'AaBbCcDDddEEEeee1234566777888899999000000')
$oPost4 = _IEGetObjByName($oIE, 'view_post')
_IEAction($oPost4, "click")
_IEAttach("Facebook")
_IENavigate($oIE, "https://m.facebook.com/groups/2/") ;2

$oPost5 = _IEGetObjByName($oIE, 'xc_message')
_IEFormElementSetValue($oPost5, 'AaBbCcDDddEEEeee1234566777888899999000000')
$oPost6 = _IEGetObjByName($oIE, 'view_post')
_IEAction($oPost6, "click")
#include <IE.au3>
Global $oLinks, $oForm, $oIE, $sURL, $iFlag = 0
$oIE = _IEAttach("Facebook")
If @error Then Exit 1

$oLinks = _IETagNameGetCollection($oIE, "a")
If @error Then Exit 2
$iFlag = 0
For $oLink In $oLinks
    If StringInStr(_IEPropertyGet($oLink, "outertext"), "Logout") > 0 Then
        $iFlag = 1
        _IEAction($oLink, "focus")
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next
If Not $iFlag Then Exit 3

all of these works properly if run it separately, but I can't join all together for working without errors

need it for post news on my groups

can you help me pls:blink:

Share this post


Link to post
Share on other sites



Next time, show us the combined code along with the errors that are occurring. Here's an untested version:

include <IE.au3>

Local $sLogin = 'login@mail.com'
Local $sPass = 'password'
Local $sUrl = "m.facebook.com"

Local $oIE = _IECreate($sUrl)
Local $hWnd = _IEPropertyGet($oIE, "hwnd")

WinSetState($hWnd, "", @SW_MAXIMIZE)

Login()
Group1()
Group2()
Logout()

Func Login()
$oLogin = _IEGetObjByName($oIE, 'email')
$oPass = _IEGetObjByName($oIE, 'pass')
_IEFormElementSetValue($oLogin, $sLogin)
_IEFormElementSetValue($oPass, $sPass)
$oButton = _IEGetObjByName($oIE, 'login')
_IEAction($oButton, 'click')
EndFunc

Func Group1()
_IENavigate($oIE, "https://m.facebook.com/groups/1/") ;1

$oPost3 = _IEGetObjByName($oIE, 'xc_message')
_IEFormElementSetValue($oPost3, 'AaBbCcDDddEEEeee1234566777888899999000000')
$oPost4 = _IEGetObjByName($oIE, 'view_post')
_IEAction($oPost4, "click")
EndFunc

Func Group2()
_IENavigate($oIE, "https://m.facebook.com/groups/2/") ;2

$oPost5 = _IEGetObjByName($oIE, 'xc_message')
_IEFormElementSetValue($oPost5, 'AaBbCcDDddEEEeee1234566777888899999000000')
$oPost6 = _IEGetObjByName($oIE, 'view_post')
_IEAction($oPost6, "click")
EndFunc

Func Logout()
Local $oLinks, $oForm, $sURL, $iFlag = 0

$oLinks = _IETagNameGetCollection($oIE, "a")
If @error Then Exit 1

$iFlag = 0
For $oLink In $oLinks
    If StringInStr(_IEPropertyGet($oLink, "outertext"), "Logout") > 0 Then
        $iFlag = 1
        _IEAction($oLink, "focus")
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next
If Not $iFlag Then Exit 2
EndFunc

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

getiing this error:

"C:\Program Files\AutoIt3\Include\IE.au3" (272) : ==> The requested action with this object has failed.:
$oObject.navigate($sUrl)
$oObject^ ERROR

using latest stable version AutoIt v3.3.14.2

if you want I can send you an account for testing

Edited by blackandwhite
mist

Share this post


Link to post
Share on other sites

sorry, may be this is noob code, but its trying to navigate to GROUP_1 before before authorization on website, and there are no errors return for me

#include <IE.au3>
#include <msgboxconstants.au3>

Local $sLogin = 'login@mail.com'
Local $sPass = 'password'
Local $sUrl = "m.facebook.com"

Login1()
Func Login1()

Global $oIE = _IECreate($sUrl)
;WinSetState($hWnd, "", @SW_MAXIMIZE)

    If @error Then
        MsgBox($MB_ICONERROR, '_IECreate', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(1,0,0)
    Endif
Local $hWnd = _IEPropertyGet($oIE, "hwnd")
    If @error Then
        MsgBox($MB_ICONERROR, '_IEPropertyGet', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(2,0,0)
    Endif
EndFunc


Login()
Group1()


Func Login()
$oLogin = _IEGetObjByName($oIE, 'email')
    If @error Then
        MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(3,0,0)
    Endif
$oPass = _IEGetObjByName($oIE, 'pass')
    If @error Then
        MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(4,0,0)
    Endif
_IEFormElementSetValue($oLogin, $sLogin)
    If @error Then
        MsgBox($MB_ICONERROR, '_IEFormElementSetValue', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(5,0,0)
    Endif
_IEFormElementSetValue($oPass, $sPass)
    If @error Then
        MsgBox($MB_ICONERROR, '_IEFormElementSetValue', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(6,0,0)
    Endif
$oButton = _IEGetObjByName($oIE, 'login')
    If @error Then
        MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(7,0,0)
    Endif
_IEAction($oButton, 'click')
    If @error Then
        MsgBox($MB_ICONERROR, '_IEAction', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(8,0,0)
    Endif
EndFunc

Func Group1()
_IENavigate($oIE, "https://m.facebook.com/groups1/") ;1
    If @error Then
        MsgBox($MB_ICONERROR, '_IENavigate', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(9,0,0)
    Endif

$oPost3 = _IEGetObjByName($oIE, 'xc_message')
    If @error Then
        MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(10,0,0)
    Endif
_IEFormElementSetValue($oPost3, 'AaBbCcDDddEEEeee1234566777888899999000000')
    If @error Then
        MsgBox($MB_ICONERROR, '_IEFormElementSetValue', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(11,0,0)
    Endif
$oPost4 = _IEGetObjByName($oIE, 'view_post')
    If @error Then
        MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(12,0,0)
    Endif
_IEAction($oPost4, "click")
    If @error Then
        MsgBox($MB_ICONERROR, '_IEAction', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        ; Set @error when you return from function with Failure
        Return SetError(13,0,0)
    Endif
EndFunc

also tried with this:

While _IEPropertyGet($oIE, "busy") = True
    Sleep(50); wait while IE is busy
WEnd

and

;just
Sleep(4000)

or

_IENavigate($oIE, "https://group_1") ;with different parameters
_IELoadWait($oIE) ;with different parameters

no luck, still navigating before login ends

Share this post


Link to post
Share on other sites

of course :blink:

Share this post


Link to post
Share on other sites

also checked with old Autoit versions, nooo luck :o

still start navigating before login ends

Share this post


Link to post
Share on other sites

Suggest that you post a highly simplified version of your script that demonstrates the issue. Also, be sure to include the version of OS, IE, AutoIT, etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now