Results 1 to 28 of 28

Thread: [RESOLVED] A few questions...?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Resolved [RESOLVED] A few questions...?

    Hi,

    I want to do three things:

    1.) How can I make it so that when a user clicks a button, it opens MSN Messenger and logs in to an account using info from two textboxes in my app?

    2.) How can I make it so that when a certain conversation window in MSN is open (using the title ex: myname - Conversation) it gets text from a .txt file and then sends it to the certain conversation (myname - Conversation) and then closes the window?

    3.) How can I make something that opens all online conversations in MSN and sends something to all of them and then exits?

    Thanks for the help.
    Last edited by JBD2; Jul 26th, 2005 at 12:53 PM.

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Re: A few questions...?

    This is possible,

    Use shellexecute (to launch MSN messanger) and use sendkeys to control the programs windows. You will need an API to see what text is in the window title bar so you know when to use sendkeys.

    Hopefully this gives you a start.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Yes, that helps, but how do I actually log-in a .NET passport with a username/password from the textboxes...same thing?

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    you will have to use sendmessage with wm_Settext or wm_char to send text to a textbox. With wm_char you have to send one letter at a time btw..

    To grab the text, use sendmessage with wm_gettext

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Cool thanks |2eM!x, but is there a way I can hide the login window while its doing that, and then once it's logged in, show the window?

  6. #6
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Re: A few questions...?

    Hmm.. that sounds a wee bit malicious... There might be a way to hide a programs window, in fact I’m sure it's possible, but it will take allot of fancy api work.

  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    Yeah sure.
    VB Code:
    1. Const SWP_HIDEWINDOW = &H80
    2. Const SWP_SHOWWINDOW = &H40
    3. Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    5. Public Declare Sub SetWindowPos Lib "user32" _
    6. (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
    7.     ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    8. Type RECT
    9.         Left As Long
    10.         Top As Long
    11.         Right As Long
    12.         Bottom As Long
    13. End Type
    14.  
    15. Private Sub Form_Load()
    16. Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
    17. Dim classname as string,tWnd as long,WinRect as Rect
    18. classname = "MSNLOGINWINDOW"
    19. tWnd = FindWindow(classname, vbNullString)
    20.     If tWnd <> 0 Then
    21.          Oleft = sizeofwin.Left: oTop = sizeofwin.Top: oRight = sizeofwin.Right: oBottom = sizeofwin.Bottom
    22.         GetWindowRect tWnd, WinRect
    23.         SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
    24.      End if
    25. Private Sub Form_Unload()
    26.  SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    27.   SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    28. End Sub
    That should do it ; )

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Thanks, and I'm just making my own login screen for MSN and sending custom messages to people like "hey what's up" etc...

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    I'm getting this error:

    Cannot define a user-defined type within a private object module.

    How do I fix this?

  10. #10
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Re: A few questions...?

    Change to Private Type, you gota change all your Declares to private if you're going to put them on your form.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    I still have a problem. I have this code:

    VB Code:
    1. Const SWP_HIDEWINDOW = &H80
    2. Const SWP_SHOWWINDOW = &H40
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    5. Private Declare Sub SetWindowPos Lib "user32" _
    6. (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
    7.     ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    8. Private Type RECT
    9.         Left As Long
    10.         Top As Long
    11.         Right As Long
    12.         Bottom As Long
    13. End Type
    14.  
    15. Private Sub Form_Load()
    16. Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
    17. Dim classname As String, tWnd As Long, WinRect As RECT
    18. classname = "theclassname"
    19. tWnd = FindWindow(classname, vbNullString)
    20.     If tWnd <> 0 Then
    21.          Oleft = sizeofwin.Left: oTop = sizeofwin.Top: oRight = sizeofwin.Right: oBottom = sizeofwin.Bottom
    22.         GetWindowRect tWnd, WinRect
    23.         SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
    24.      End If
    25. End Sub
    26.  
    27. Private Sub Form_Unload()
    28.   SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    29.   SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    30. End Sub

    Except this time, my problem is:

    Procedure declaration does not match description of event or procedure having same name.

    And the highlighted text is:

    Private Sub Form_Unload

    How can I fix this?

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: A few questions...?

    Try the Form_QueryUnload instead of Form_Unload.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Same Error

  14. #14
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: A few questions...?

    Your variables are out of scope. Declare them before the Form_Load
    I had tried queryunload, and didn't have an error, but did get an error in the load module. Now in a simple test, I msgbox'ed a variable that I defined in load, and got a variable not defined error.

    VB Code:
    1. Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long

  15. #15
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: A few questions...?

    Its because the Unload and QueryUnload you typed isn't what it is supposed to be:
    VB Code:
    1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    2.  
    3. End Sub
    4.  
    5. Private Sub Form_Unload(Cancel As Integer)
    6.  
    7. End Sub
    Use one of those..

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  16. #16
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    those variables are not losing scope, as chem said above you need Cancel As integer for form unload

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Ok now it wants me to define, "sizeofwin"...What would this be declared as?

  18. #18
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    sorry. change all sizeofwins to winRect...my bad

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Ok that worked, but there's one last problem. It says "variable not defined". Highlights "tWnd". Should this be hWnd?

  20. #20
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    VB Code:
    1. Const SWP_HIDEWINDOW = &H80
    2. Const SWP_SHOWWINDOW = &H40
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    5. Private Declare Sub SetWindowPos Lib "user32" _
    6. (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
    7.     ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    8. Private Type RECT
    9.         Left As Long
    10.         Top As Long
    11.         Right As Long
    12.         Bottom As Long
    13. End Type
    14. Dim tWnd As Long
    15. Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
    16.  
    17. Private Sub Form_Load()
    18. Dim classname As String, WinRect As RECT
    19. classname = "theclassname"
    20. tWnd = FindWindow(classname, vbNullString)
    21.     If tWnd <> 0 Then
    22.          Oleft =WinRect .Left: oTop = WinRect .Top: oRight = WinRect .Right: oBottom = WinRect .Bottom
    23.         GetWindowRect tWnd, WinRect
    24.         SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
    25.      End If
    26. End Sub
    27.  
    28. Private Sub Form_Unload()
    29.   SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    30.   SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    31. End Sub

    I think your using tWnd in a sub that isnt form_load, so now try it

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Now when I unload, my msn still isn't showing up...I can't see it now.

  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Here's my code:

    VB Code:
    1. Const SWP_HIDEWINDOW = &H80
    2. Const SWP_SHOWWINDOW = &H40
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    5. Private Declare Sub SetWindowPos Lib "user32" _
    6. (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
    7.     ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    8. Private Type RECT
    9.         Left As Long
    10.         Top As Long
    11.         Right As Long
    12.         Bottom As Long
    13. End Type
    14. Dim tWnd As Long
    15. Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
    16.  
    17. Private Sub Form_Load()
    18. Dim classname As String, WinRect As RECT
    19. classname = "#32770"
    20. tWnd = FindWindow(classname, vbNullString)
    21.     If tWnd <> 0 Then
    22.          Oleft = WinRect.Left: oTop = WinRect.Top: oRight = WinRect.Right: oBottom = WinRect.Bottom
    23.         GetWindowRect tWnd, WinRect
    24.         SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
    25.      End If
    26. End Sub
    27.  
    28. Private Sub Form_Unload(Cancel As Integer)
    29.   SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    30.   SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    31. End Sub

    What's the problem?

    200th post

  23. #23
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    If tWnd <> 0 Then
    GetWindowRect tWnd, WinRect
    Oleft = WinRect.Left: oTop = WinRect.Top: oRight = WinRect.Right: oBottom = WinRect.Bottom
    SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
    End If

  24. #24

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Where does this go...If in form_unload, does it replace the other code?

  25. #25
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    it replaces the old code...i was assigning values before getting them

  26. #26

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    I get this error:

    ByRef argument type mismatch

    And it highlights this:

    WinRect

  27. #27
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: A few questions...?

    VB Code:
    1. Const SWP_HIDEWINDOW = &H80
    2. Const SWP_SHOWWINDOW = &H40
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    5. Private Declare Sub SetWindowPos Lib "user32" _
    6. (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
    7.     ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    8. Private Type RECT
    9.         Left As Long
    10.         Top As Long
    11.         Right As Long
    12.         Bottom As Long
    13. End Type
    14. Dim tWnd As Long
    15. Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
    16. Dim  WinRect As RECT
    17. Private Sub Form_Load()
    18. Dim classname As String
    19. classname = "#32770"
    20. tWnd = FindWindow(classname, vbNullString)
    21.     If tWnd <> 0 Then
    22.          Oleft = WinRect.Left: oTop = WinRect.Top: oRight = WinRect.Right: oBottom = WinRect.Bottom
    23.         GetWindowRect tWnd, WinRect
    24.         SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
    25.      End If
    26. End Sub
    27.  
    28. Private Sub Form_Unload(Cancel As Integer)
    29.   SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    30.   SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
    31. End Sub
    That should finally work. Sorry, but i dont have vb so im writing directly to the browser

  28. #28

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: A few questions...?

    Thanks that works.

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