|
-
Jul 26th, 2005, 12:28 PM
#1
Thread Starter
Fanatic Member
[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.
-
Jul 26th, 2005, 01:26 PM
#2
Fanatic Member
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.
-
Jul 26th, 2005, 01:29 PM
#3
Thread Starter
Fanatic Member
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?
-
Jul 26th, 2005, 01:46 PM
#4
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
-
Jul 26th, 2005, 01:55 PM
#5
Thread Starter
Fanatic Member
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?
-
Jul 26th, 2005, 01:59 PM
#6
Fanatic Member
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.
-
Jul 26th, 2005, 02:06 PM
#7
Re: A few questions...?
Yeah sure.
VB Code:
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Public Declare Sub SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
Dim classname as string,tWnd as long,WinRect as Rect
classname = "MSNLOGINWINDOW"
tWnd = FindWindow(classname, vbNullString)
If tWnd <> 0 Then
Oleft = sizeofwin.Left: oTop = sizeofwin.Top: oRight = sizeofwin.Right: oBottom = sizeofwin.Bottom
GetWindowRect tWnd, WinRect
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
End if
Private Sub Form_Unload()
SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
End Sub
That should do it ; )
-
Jul 26th, 2005, 02:24 PM
#8
Thread Starter
Fanatic Member
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...
-
Jul 26th, 2005, 02:26 PM
#9
Thread Starter
Fanatic Member
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?
-
Jul 26th, 2005, 02:31 PM
#10
Fanatic Member
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.
-
Jul 26th, 2005, 05:11 PM
#11
Thread Starter
Fanatic Member
Re: A few questions...?
I still have a problem. I have this code:
VB Code:
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Sub SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
Dim classname As String, tWnd As Long, WinRect As RECT
classname = "theclassname"
tWnd = FindWindow(classname, vbNullString)
If tWnd <> 0 Then
Oleft = sizeofwin.Left: oTop = sizeofwin.Top: oRight = sizeofwin.Right: oBottom = sizeofwin.Bottom
GetWindowRect tWnd, WinRect
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
End If
End Sub
Private Sub Form_Unload()
SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
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?
-
Jul 26th, 2005, 05:49 PM
#12
Re: A few questions...?
Try the Form_QueryUnload instead of Form_Unload.
-
Jul 26th, 2005, 06:01 PM
#13
Thread Starter
Fanatic Member
-
Jul 26th, 2005, 06:06 PM
#14
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:
Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
-
Jul 26th, 2005, 06:07 PM
#15
Re: A few questions...?
Its because the Unload and QueryUnload you typed isn't what it is supposed to be:
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
End Sub
Private Sub Form_Unload(Cancel As Integer)
End Sub
Use one of those..
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Jul 26th, 2005, 06:14 PM
#16
Re: A few questions...?
those variables are not losing scope, as chem said above you need Cancel As integer for form unload
-
Jul 26th, 2005, 06:17 PM
#17
Thread Starter
Fanatic Member
Re: A few questions...?
Ok now it wants me to define, "sizeofwin"...What would this be declared as?
-
Jul 26th, 2005, 06:20 PM
#18
Re: A few questions...?
sorry. change all sizeofwins to winRect...my bad
-
Jul 26th, 2005, 06:22 PM
#19
Thread Starter
Fanatic Member
Re: A few questions...?
Ok that worked, but there's one last problem. It says "variable not defined". Highlights "tWnd". Should this be hWnd?
-
Jul 26th, 2005, 06:25 PM
#20
Re: A few questions...?
VB Code:
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Sub SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim tWnd As Long
Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
Private Sub Form_Load()
Dim classname As String, WinRect As RECT
classname = "theclassname"
tWnd = FindWindow(classname, vbNullString)
If tWnd <> 0 Then
Oleft =WinRect .Left: oTop = WinRect .Top: oRight = WinRect .Right: oBottom = WinRect .Bottom
GetWindowRect tWnd, WinRect
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
End If
End Sub
Private Sub Form_Unload()
SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
End Sub
I think your using tWnd in a sub that isnt form_load, so now try it
-
Jul 26th, 2005, 06:28 PM
#21
Thread Starter
Fanatic Member
Re: A few questions...?
Now when I unload, my msn still isn't showing up...I can't see it now.
-
Jul 26th, 2005, 06:42 PM
#22
Thread Starter
Fanatic Member
Re: A few questions...?
Here's my code:
VB Code:
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Sub SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim tWnd As Long
Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
Private Sub Form_Load()
Dim classname As String, WinRect As RECT
classname = "#32770"
tWnd = FindWindow(classname, vbNullString)
If tWnd <> 0 Then
Oleft = WinRect.Left: oTop = WinRect.Top: oRight = WinRect.Right: oBottom = WinRect.Bottom
GetWindowRect tWnd, WinRect
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
End Sub
What's the problem?
200th post
-
Jul 26th, 2005, 06:46 PM
#23
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
-
Jul 26th, 2005, 06:51 PM
#24
Thread Starter
Fanatic Member
Re: A few questions...?
Where does this go...If in form_unload, does it replace the other code?
-
Jul 26th, 2005, 06:54 PM
#25
Re: A few questions...?
it replaces the old code...i was assigning values before getting them
-
Jul 26th, 2005, 06:56 PM
#26
Thread Starter
Fanatic Member
Re: A few questions...?
I get this error:
ByRef argument type mismatch
And it highlights this:
WinRect
-
Jul 26th, 2005, 07:00 PM
#27
Re: A few questions...?
VB Code:
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Sub SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim tWnd As Long
Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
Dim WinRect As RECT
Private Sub Form_Load()
Dim classname As String
classname = "#32770"
tWnd = FindWindow(classname, vbNullString)
If tWnd <> 0 Then
Oleft = WinRect.Left: oTop = WinRect.Top: oRight = WinRect.Right: oBottom = WinRect.Bottom
GetWindowRect tWnd, WinRect
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
End Sub
That should finally work. Sorry, but i dont have vb so im writing directly to the browser
-
Jul 26th, 2005, 07:04 PM
#28
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|