I've got the following code. It works fine at win 98 but it gives an error ("invalid function call or argument") somewhere in this piece of code (I think).
can anybody help me??
bWnd = GetWindow(tWnd, GW_CHILD)
List1.AddItem Time$ + " Searching for Passwordbox..."
Print #1, Time$ + " Searching for Passwordbox..."
StartTime = Time
Do
Label1.Caption = "Searching for Passwordbox " + Format$(Time - StartTime, "hh:mm:ss")
sSave = Space(250)
GetClassName bWnd, sSave, 250
sSave = Left$(sSave, Len(RTrim(sSave)) - 1)
If (LCase(sSave) = LCase(Combo1.Text)) Then
lngLen = SendMessage(bWnd, WM_GETTEXTLENGTH, 0, 0)
str = Space(lngLen)
Call SendMessage(bWnd, WM_GETTEXT, lngLen, ByVal str)
If (str = "") Then
Exit Do
End If
End If
If (bWnd = 0) Then
bWnd = GetWindow(tWnd, GW_CHILD)
Else
bWnd = GetWindow(bWnd, GW_HWNDNEXT)
End If
DoEvents: DoEvents: DoEvents
Loop Until (DoLock = False) Or (FormLoaded(tWnd) = False)
If (DoLock = False) Then GoTo Abort
List1.AddItem Time$ + " Passwordbox Found (" + Hex$(bWnd) + ")"
Label1.Caption = "Unable to lock"
Loop Until bWnd <> 0
that's right, it is meant to find the textbox in the loginwindow from messenger (msn) en check wat text it contained. and it worked exept with winXP. the problem must be in this peace of code but if you like the complete project you can have it. it's quite simple.
I wont mind, cuz i'm also dutch.
And i don't think it's against the rules because my program which decodes the MSN password from the registry is posted here somewhere too.
I'll take a look at the program now.
The bug occurs in the LockIt() Function. It happens when you try to use Left$(sSave, Len(RTrim(sSave)) - 1). The length becomes zero when when you trim sSave when it only contains spaces.
I presume this happens only once, so an "On Error Resume Next" would fix it. I've tried it out, but it only finds the window and not the password box. Don't know how long it should take, though.
Here's the code i changed:
<code>
Do
Label1.Caption = "Searching for Passwordbox " + Format$(Time - StartTime, "hh:mm:ss")
sSave = Space(250)
GetClassName bWnd, sSave, 250
On Error Resume Next '<-- added this
sSave = Left$(sSave, Len(RTrim(sSave)) - 1) '<-- gives error
</code>
it's realy important that you select win XP or win 98 (but win XP doesn't work) and you select edit.
and it doesn't work when you have remember password selected. becouse it lockes on an empty edit.
and (but I think you know that) it's important that you change the caption of the window where it searches for (becouse I'm dutch and the program is dutch too).