Jump to content
Sign in to follow this  
Mithrandir

Help to Logout from a forum

Recommended Posts

Mithrandir

I have problems to logout from a forum but I think I cannot avoid the window that appears, here it is what I have made:

#include <IE.au3>
$oIE = _IECreate ("http://forums.linkbucks.com/")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 0)
$oQuery2 = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oQuery, "username")
_IEFormElementSetValue ($oQuery2, "password")
_IEFormSubmit ($oForm)
Sleep(10000);I would prefer not having to rely on this :P
_IELinkClickByText ($oIE, "Log Out")
Sleep(10000);I would prefer not having to rely on this :P
Send("{ENTER}");i thought that it would function as the window is set to active by default :S

I decided to use windows controls as it is suggested in the help file cause in the autoit window info there isn't a control called "Internet Explorer_Server" :

Remarks
_IEAttach provides the "dialogbox" parameter to attach to modal and modeless dialogs created by the browser. It is important to note that not all dialogs created through browser interaction can be attached to and controlled in this way. Many of these dialogs are actually standard windows and can be controlled through the traditional AutoIt window functions. A reliable way to tell the difference between these types of windows is to use the "AutoIt Window Info" tool to examine it -- if the window contains a control called "Internet Explorer_Server" then you can attach to it with this function, if it does not it is a standard window and traditional AutoIt windows functions must be used to control it.

Here is the code:

#include <IE.au3>
$oIE = _IECreate ("http://forums.linkbucks.com/")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 0)
$oQuery2 = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oQuery, "username")
_IEFormElementSetValue ($oQuery2, "password")
_IEFormSubmit ($oForm)
Sleep(10000)
_IELinkClickByText ($oIE, "Log Out")
WinWaitActive("Windows Internet Explorer", "", 5)
Send("{ENTER}")
; In the line of WinWaitActive I also tried using _IEAction ($oIE2, "focus")
;and ControlClick("Windows Internet Explorer", "Aceptar", "1") just in case but I don't think this will function cause it's a normal window

Here is the window that appears:

post-50235-1244863519_thumb.jpg

and here the info of the window:

post-50235-1244863553_thumb.jpg

and here the info of the 'Aceptar' Button:

post-50235-1244863606_thumb.jpg

I also tried using IEManagement functions and I had errors (maybe this confirms that I have to consider it as a normal window?):

#include <IE.au3>
$oIE = _IECreate ("http://forums.linkbucks.com/")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 0)
$oQuery2 = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oQuery, "username")
_IEFormElementSetValue ($oQuery2, "password")
_IEFormSubmit ($oForm)
Sleep(10000)
_IELinkClickByText ($oIE, "Log Out")
$oIE2 = _IEAttach ("Windows Internet Explorer", "dialogbox")
_IEAction ($oIE2, "focus")
ControlSend("Windows Internet Explorer", "Aceptar", 1, "{ENTER}")

>"C:\Archivos de programa\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\Pablo\Escritorio\TEST PARA DESLOGUEARME 2.au3" /autoit3dir "C:\Archivos de programa\AutoIt3" /UserParams  
+>13:16:09 Starting AutoIt3Wrapper v.2.0.0.1    Environment(Language:0C0A  Keyboard:0000040A  OS:WIN_XP/Service Pack 3  CPU:X86 OS:X86)
>Running AU3Check (1.54.14.0)  from:C:\Archivos de programa\AutoIt3
+>13:16:09 AU3Check ended.rc:0
>Running:(3.3.0.0):C:\Archivos de programa\AutoIt3\autoit3.exe "C:\Documents and Settings\Pablo\Escritorio\TEST PARA DESLOGUEARME 2.au3"    
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidObjectType
+>13:17:04 AutoIT3.exe ended.rc:0
+>13:17:05 AutoIt3Wrapper Finished
>Exit code: 0   Time: 57.401

Share this post


Link to post
Share on other sites
DCCD

give it a try!

#include <IE.au3>
;
$oIE = _IECreate("http://forums.linkbucks.com/")
$logou = _IELinkClickByText($oIE, "Log Out")
If $logou = 0 Then
    MsgBox(0, "", "not login yet")
Else
    $WinW = WinWaitActive("Windows Internet Explorer")
    If $WinW = 1 Then
        ControlClick("Windows Internet Explorer", "", "[CLASS:Button]")
    EndIf
EndIf
Edited by DCCD

Share this post


Link to post
Share on other sites
Mithrandir

give it a try!

#include <IE.au3>
;
$oIE = _IECreate("http://forums.linkbucks.com/")
$logou = _IELinkClickByText($oIE, "Log Out")
If $logou = 0 Then
    MsgBox(0, "", "not login yet")
Else
    $WinW = WinWaitActive("Windows Internet Explorer")
    If $WinW = 1 Then
        ControlClick("Windows Internet Explorer", "", "[CLASS:Button]")
    EndIf
EndIf
DCCD: I tried your code with mine like this:

#include <IE.au3>
;
$oIE = _IECreate("http://forums.linkbucks.com/")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 0)
$oQuery2 = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oQuery, "username")
_IEFormElementSetValue ($oQuery2, "password")
_IEFormSubmit ($oForm)
Sleep(15000)
$logou = _IELinkClickByText($oIE, "Log Out")
If $logou = 0 Then
    MsgBox(0, "", "not login yet")
Else
    $WinW = WinWaitActive("Windows Internet Explorer")
    If $WinW = 1 Then
        ControlClick("Windows Internet Explorer", "", "[CLASS:Button]")
    EndIf
EndIf

But it didn't functioned and there weren't any errors reported. I then tried your code alone and as I was not logged in the box saying "not login yet" appeared.

Share this post


Link to post
Share on other sites
Mithrandir

Wanna Login then Logout?!!

Yes in fact what i want to do is log in post and log out here is the complete code I have made:

#include <IE.au3>
$oIE = _IECreate ("http://forums.linkbucks.com/newthread.php?do=newthread&f=12")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 0);the username field
$oQuery2 = _IEFormElementGetCollection ($oForm, 2);the password field
_IEFormElementSetValue ($oQuery, "username")
_IEFormElementSetValue ($oQuery2, "password")
_IEFormSubmit ($oForm)
$oForm1 = _IEFormGetObjByName ($oIE, "vbform")
$oQuery3 = _IEFormElementGetObjByName ($oForm1, "subject")
$oQuery4 = _IEFormElementGetObjByName ($oForm1, "message")
_IEFormElementSetValue ($oQuery3, "my test")
_IEFormElementSetValue ($oQuery4, "this is my new test")
_IEFormSubmit ($oForm1)

;then I have tried the ways in the above posts here is another one:
_IELinkClickByText ($oIE, "Log Out")

Sleep(5000)

ControlClick("Windows Internet Explorer", "Are you sure you want to log out?", "1")

Someone suggested me to use

FileDelete(@UserProfileDir & "\Cookies\*.txt")
to delete the cookies thus loggin out but in @UserProfileDir I have to input the adress of the internet explorer cookies no? Edited by Mithrandir

Share this post


Link to post
Share on other sites
Mithrandir

Where do you get [vbform, subject, message] from?! coz I can't find them in any html.!!

How can you submit form if there is no name!? but there's good news too! :D create your own FORM-action.

see ya tomorrow...zzZZzZ

I got all the info using IE-Builder http://www.autoitscript.com/forum/index.ph...mp;#entry133767 and here how to fix it http://www.autoitscript.com/forum/index.ph...st&p=690565 : I got vbform in html elements (its index number is 178) and I got subject and message in form elements (index numbers 0 and 1)

Another good tool is Debugbar...

Anyway I don't understand what you mean by "create your own FORM-action"¿?

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
Sign in to follow this  

×