Results 1 to 23 of 23

Thread: [RESOLVED] [2008] Doubble click on program = login to game?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Resolved [RESOLVED] [2008] Doubble click on program = login to game?

    Hi dear peaples! I'm pretty newbie at programming (but i am reading guides ETC) so im going to be better and better..

    Well. I need to make a program that is autologin me.

    Also when i open the client it will open a game i play
    (http://www.habbo.se/client) Then there it will write automatic my name and password and login to it.

    The problem is that my computer is slow or something. When i go on habbo.se it can takes from 30 secounds to 5 minutes to login.´
    While in game its no lagg :S

    Well, is this possible to make?

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    If you're just talking about automating a website, which is what it sounds like, then search these forums for how to use the WebBrowser control that comes with Visual Studio (in the toolbox on the left)
    I think one of the users on here named "Kleinma" has a good link in his signature.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2008] Doubble click on program = login to game?

    yeah... I am sure kleinma is floating around here somewhere

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    Witch of them?
    i tried "Launch new default browser instance to open URL" and downloaded that OpenNewBrowser. And tried it..

    That's anyway a good start.. But when i open the file it should autologin me too, and how its possible to do it?

    [EDIT]
    Oh, now i found it..
    It were the first link in his code bank?
    http://www.vbforums.com/showthread.php?t=416275

    Will read that now..

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    Downloaded the WebPageManipulation, readed http://www.vbforums.com/showthread.php?t=416275

    And then i opened WebPageManipulation, and baam 21 errors..
    "Type 'mshtml.HTMLDocument' is not defined."
    "Type 'mshtml.IHTMLxRange' is not deined."

    And so on..
    Do i need VB 2005 or whats the errors mean?... do i need to add stuffs?

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    Have you tried adding a reference to mshtml?

    I think you might be better off just reading and understanding posts on the forums instead of trying to copy bits out of an existing project (I find it easier anyway)

    EDIT: Also, Kleinma's project doesnt use the standard web browser control that comes with VS 2005 & 2008 because he wanted more functionality than that. However, if you just want to log in to a website, that can easily be done with the standard web browser.
    Last edited by chris128; Jul 17th, 2008 at 04:43 AM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #7
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    Quote Originally Posted by 2ManyGuys
    Witch of them?
    i tried "Launch new default browser instance to open URL" and downloaded that OpenNewBrowser. And tried it..

    That's anyway a good start.. But when i open the file it should autologin me too, and how its possible to do it?

    [EDIT]
    Oh, now i found it..
    It were the first link in his code bank?
    http://www.vbforums.com/showthread.php?t=416275

    Will read that now..
    Yep thats the one.
    If you're still stuck, just search these forums as plenty of people have asked the same question before
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    :S i've search but i don't find how to do iiit.

  9. #9
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    How far have you got? Basically, the very first thing you need to do is drag a WebBrowser control from the toolbox in Visual Studio onto your form.
    From there, you need to load the website (habbohotel) into that webbrowser control using the Navigate method.
    Then, in the Document_Completed event (or whatever its called) of the WebBrowser you can loop through the HTML elements to find the text fields that you want to enter text into.
    You set their text by using InnerHTML or OuterHTML, cant remember which but just play around with it and you'll get the hang of it.
    Oh and to click the Submit/login button you could loop through the HTML elements again and look for a button with that text and if you find it then just use the InvokeMethod("Click") method and your webbrowser control will click the button for you... at least I think thats what the method is called, its something similar to that anyway.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    I know how to make a web browser, have watch for 2 days ago on tutorials at youtube there 1 included web browsers..

    But i dont understand that with Document_Completed event and that HTML things!! T_T

  11. #11
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    OK here's an example then
    Lets say you added a webbrowser to your form and named it WB

    First of all you need to navigate to the website so you would use this:
    vb Code:
    1. Dim LoginPage As New Uri("www.examplewebsiteloginpage.com")
    2. WB.Navigate(LoginPage)
    Obviously change the address to habbohotel or whatever it was that your trying to log in to.
    Now, in the designer, double click your webbrowser control and you will be taken to the code view of the Document_Completed event. Basically this event gets fired everytime your web browser finishes loading a page. So you would put the code that actually logs in to the website in that event. Like so:
    vb Code:
    1. If e.Url = logonpage Then
    2. WB.Document.All("Username").InnerText = ("MyUsername")
    3. End If
    Now you have to understand that the username box on your website might not be called "Username" so that code above would not work. You need to view the HTML source of the website and find out what the ID or name that they have given their text boxes.

    Hope that helps get you started!
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    Okey, helped me to understand more.. But how do i find the box and that!? Also witch codes it is!? :S

    And when i got it. Were im gonna type it then? on that ("Username") ?

    [EDIT]
    I tried to write


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim LoginPage As New Uri("www.habbo.se/client")
    WebBrowser1.Navigate(LoginPage)


    But it become and error.
    Last edited by 2ManyGuys; Jul 20th, 2008 at 12:37 PM.

  13. #13
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    OK, because this is just a quick thing I've made a working example for you in the hope that you will be able to learn from it.

    I'll explain each bit in detail after the code:

    vb Code:
    1. 'Declared at class level so that we can use it in more than one sub
    2. Dim loginpage As New Uri("http://www.habbo.se/login_popup")
    3.  
    4. 'I have used the form_load event to make the browser navigate to the habbohotel page
    5. 'but you could use a button click event or something like that
    6. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7. 'This line tells the browser to go to the login page
    8. WB.Navigate(loginpage)
    9. End Sub
    10.  
    11. 'This is the DocumentCompleted event that I mentioned earlier
    12. Private Sub WB_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WB.DocumentCompleted
    13. 'Here we are saying - If the URL is the login page URL then we set the text of the texboxes
    14. 'and click the submit button
    15. If e.Url = loginpage Then
    16.   WB.Document.All("login-username").InnerText = "test_username"
    17.   WB.Document.All("login-password").InnerText = "test_password"
    18.   WB.Document.All("login-submit-button").InvokeMember("click")
    19. End If
    20. End Sub

    OK so as you can see from the code, the bit that actually sets the username and password text is this:
    vb Code:
    1. WB.Document.All("login-username").InnerText = "test_username"
    2. WB.Document.All("login-password").InnerText = "test_password"
    These are the HTML bits I was talking about, the "login-username" and "login-password" are the IDs of the HTML elements on the page. I found them by opening up the habbohotel login page in Internet Explorer and right clicking and going to View Source. This opens the page's HTML source in Notepad so that we can look through it to find the bits we want... username and password boxes are usually pretty obvious. In this case its this part of the HTML source:
    Code:
    <label for="login-username" class="login-text">Habbo-namn</label>
    <input tabindex="1" type="text" class="login-field" name="credentials.username" id="login-username" value="" />
    Notice this part specifically: id="login-username". So once I knew the ID of the username box I could just use the Document.All() property of the webbrowser control to set its 'InnerText'.
    I did the same thing for the password box and then looked for the ID of the submit button in the HTML source, which in this case was: login-submit-button. Which is why I used the following code to click it:
    vb Code:
    1. WB.Document.All("login-submit-button").InvokeMember("click")

    Hopefully that helps!
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    OKey, i understand. But i got problem still. :/

    Its work with
    Dim loginpage As New Uri("http://www.habbo.se/login_popup")
    also login_popup, its succeed that its write in the usrname and pw and press the button! But its not logging into the client
    and when i press on "go into hotel" then habbo.se/client popup and say im not logged in...

    And if i write
    Dim loginpage As New Uri("http://www.habbo.se/Client")
    Also client in end.. Then its not even writing in the username and password and pressing ok!

    Is it because Habbo.se/client do not got the codes? because if i go into habbo.se/client its just transfer to login_popup.


    It is possible to fix this!? :S Also i had before a Web Browser from VBforums there they could open popups with the Web Browser without its open in IE! Might i need that!? :S

    And if i need that i must be make it when it have login me its need to press on that other button..

    Going to check the other buttons name..

    [EDIT]
    <div id="to-hotel">
    <a href="http://www.habbo.se/client" class="new-button green-button" target="client" onclick="HabboClient.openOrFocus(this); return false;"><b>Checka in p&#229; Habbo Hotel</b><i></i></a>
    </div>

    So the buttons name is "new-button green-button" !? i didn't see any ID or something, but i guess thats it..
    [edit] or its div id.. *** does that mean ? o_O
    Last edited by 2ManyGuys; Jul 20th, 2008 at 01:24 PM.

  15. #15
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    Yeah well I changed the url to the login_popup one because I noticed that it just transfers you straight to that URL when you go to the Client url. However, its possible that you need to actually let the Client page send you to the login_popup page (instead of just going straight to the login_popup) page for it to work properly so if thats the case, here is what you can do:

    Leave this bit as it is:
    vb Code:
    1. Dim loginpage As New Uri("http://www.habbo.se/login_popup")
    and leave all of the code as it is in my example (obviously change the username and password to yours though) but just change this one bit - change this:
    vb Code:
    1. WB.Navigate(loginpage)
    to this:
    vb Code:
    1. WB.Navigate("http://www.habbo.se/Client")

    So now what will happen is, your webbrowser will navigate to the Client url and then will be automatically redirected to the login_popup url so when your DocumentCompleted event fires again when it loads the login_popup page then the code will execute and log you in... then HOPEFULLY return you back to the Client page logged in.

    Having said all this, when I tested on my PC the login_popup page did not appear as a seperate popup internet explorer window or anything like that but from what you said it sounds like it does on yours. If that is the case then yeah you will need to find out how to force popups to be contained within your webbrowser control instead of launching an external window.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  16. #16

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    Okey :S Well, i tried to change that, and now its only going to locate to habbo.se .. also just normal site and nothing are happening.. o_O

  17. #17
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    Sorry I dont quite understand what you mean. Can you post the exact code you are using at the moment (hide your username and password though) and explain exactly what happens when you run this?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  18. #18

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    Okey! Now im back!

    I went to my mums house.
    So i started over the program now.. And i got the same problem still when i was last write!

    Okey, heres a picture
    http://i34.tinypic.com/9zu3p3.jpg

    When i debug (also play) the program then im only get into that site, and nothing is happening!

    Code:

    Code:
    Public Class Form1
        Dim loginpage As New Uri("http://www.habbo.se/login_popup")
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            WebBrowser1.Navigate("http://www.habbo.se/Client")
        End Sub
    
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            If e.Url = loginpage Then
                WebBrowser1.Document.All("login-username").InnerText = "-unknown-"
                WebBrowser1.Document.All("login-password").InnerText = "-unknown-"
                WebBrowser1.Document.All("login-submit-button").InvokeMember("click")
            End If
        End Sub
    End Class

    i think i see the wrong thing.. Also o_O
    Its open as habbo.se/client (in the program code anyway).
    And then its asking for loginpage to make the innertext and that.. And the loginpage = habbo.se/login_popup! And then it wont write it in the boxes because the login_popup never showes..

  19. #19
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    Ahh I see, so the login popup never shows when you run your program? In that case then you will need to find that article that you mentioned earlier that explains how to make popup windows appear within your webbrowser control.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  20. #20

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    Okey!
    Now i sat me down and thinked with my small brain! And i think i figured it out how i could do!

    Now my code is this:

    Code:
    Public Class Form1
        Dim loginpage As New Uri("http://www.habbo.se/login_popup")
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            WebBrowser1.Navigate(loginpage)
        End Sub
    
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            If Me.Text = "Habbo - Logged in" Then
                GoTo ErrorHandler
            Else
                GoTo GoGoGo
            End If
    GoGoGo:
            If e.Url = loginpage Then
                WebBrowser1.Document.All("login-username").InnerText = "-unknown-"
                WebBrowser1.Document.All("login-password").InnerText = "-unknown-"
                WebBrowser1.Document.All("login-submit-button").InvokeMember("click")
                Timer1.Enabled = True
            End If
    ErrorHandler:
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Me.Text = "Habbo - Logged in"
            Timer1.Enabled = True
            WebBrowser1.Navigate("http://www.habbo.se/client")
        End Sub
    End Class
    The problem i got right now is that its continue go to the client! I need to make that its only happend 1 time! Because as you see it will go to http://www.habbo.se/client all the time!!!

    How i stop it? =)


    [EDIT]
    There after the "errorhandler:" there i would write a code right!? but what would i write there to stop it make it go to habbo.se/client? o_O



    [EDIT]

    STUPID by me! i meant to make false on the timer.. and put it in front of the changing text on the form!

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Timer1.Enabled = False
    Me.Text = "Habbo - Logged in"
    WebBrowser1.Navigate("http://www.habbo.se/client")
    End Sub





    And code works fine THANKS!!! Rates u 99999999/10
    Last edited by 2ManyGuys; Jul 20th, 2008 at 03:35 PM.

  21. #21
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Doubble click on program = login to game?

    Oh ok so your using a timer to go back to the Client page after you have logged in to the login-popup page?
    If you want to do it that way then you just need to change this:
    vb Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.         Me.Text = "Habbo - Logged in"
    3.         Timer1.Enabled = True
    4.         WebBrowser1.Navigate("http://www.habbo.se/client")
    5.     End Sub
    To this:
    vb Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.         Me.Text = "Habbo - Logged in"
    3.         Timer1.Enabled = False
    4.         WebBrowser1.Navigate("http://www.habbo.se/client")
    5.     End Sub
    All I have done is changed the Timer1.Enabled = True line to Timer1.Enabled = False. This way, the first time your timer executes it will just cancel itself which means it wont fire its tick event again after the first time.

    Its worth noting though that a timer is not a good idea when it comes to automating websites becuase what would happen if the login page takes longer to process your login than normal and then your timer tick event fires before you are actually successfully logged in?
    Last edited by chris128; Jul 20th, 2008 at 03:35 PM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  22. #22

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: [2008] Doubble click on program = login to game?

    Quote Originally Posted by chris128
    Oh ok so your using a timer to go back to the Client page after you have logged in to the login-popup page?
    If you want to do it that way then you just need to change this:
    vb Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.         Me.Text = "Habbo - Logged in"
    3.         Timer1.Enabled = True
    4.         WebBrowser1.Navigate("http://www.habbo.se/client")
    5.     End Sub
    To this:
    vb Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.         Me.Text = "Habbo - Logged in"
    3.         Timer1.Enabled = False
    4.         WebBrowser1.Navigate("http://www.habbo.se/client")
    5.     End Sub
    All I have done is changed the Timer1.Enabled = True line to Timer1.Enabled = False. This way, the first time your timer executes it will just cancel itself which means it wont fire its tick event again after the first time.

    Its worth noting though that a timer is not a good idea when it comes to automating websites becuase what would happen if the login page takes longer to process your login than normal and then your timer tick event fires before you are actually successfully logged in?

    o_O yah, but it works ty ^^,

  23. #23
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] [2008] Doubble click on program = login to game?

    good good thanks for the rating
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width