VB6 autologin request for help

05/06/2009 21:46 lazlo#1
Hello,

I am writing an autologin in VB6. i am having a problem that i have been fighting for about 3 weeks now. whenever i set my name and password it shows it on the client screen, but the client doesnt recognise it.

Code:
PostMessage FlashWindow, WndMsg.WM_MOUSEACTIVATE, ConquerWindow, WndMsg.WM_LBUTTONDOWN
PostMessage FlashWindow, WndMsg.WM_SETCURSOR, FlashWindow, WndMsg.WM_LBUTTONDOWN
PostMessage FlashWindow, WndMsg.WM_LBUTTONDOWN, 1, &H2B20248
PostMessage FlashWindow, WndMsg.WM_LBUTTONUP, 0, &H2B24208
For i = 1 To Len(Text3.Text)
PostMessage FlashWindow, WndMsg.WM_CHAR, Asc(Mid$(Text3.Text,i, 1)), 0
Next i
This is the code that is not working. Should i be using a different API?
I assure you that my handles are correct.

I am not looking for someone to give me a handout of code, just a push in the right direction. Also, if there is another post about this somewhere, i appologize. I did search the forums first.

Riddled with confusion,
Lazlo
05/06/2009 21:49 clintonselke#2
Nope... the API ur using is fine. The problem is the conquer log-in screen does not respond to key-press events. It will only respond to a key-down event followed by a key-up event.

Edit: what i mean is instead of WM_CHAR, use a WM_KEYDOWN, delay a bit, then follow it with a WM_KEYUP for each key press.
05/06/2009 23:30 lazlo#3
I tried that as well. I get the same result. With the WM_CHAR though, I am not sure about the lParam. I have set it up like this:
Code:
        PostMessage FlashWindow, WndMsg.WM_KEYDOWN, &H44, 0
        Sleep 200
        PostMessage FlashWindow, WndMsg.WM_KEYUP, 0, 0
        Sleep 200
I have tried using the vk constants and the vbkey to no avail. No matter what I do, I get the same results, or it just doesn't work.
05/06/2009 23:31 Alexios#4
I want to add that clinton have already made an autologin in AutoIt.
If you just want a autologin you can use his :p
Edit: [Only registered and activated users can see links. Click Here To Register...]
If you want download AutoIt, just google it :D
05/07/2009 01:06 Belth#5
I had/have the same problem in autoit. clinton's solution was more of an alternative than a fix. I assume you're getting the "Wrong password" message not the "Failed to login: Invalid account or password!" message.
05/07/2009 03:25 lazlo#6
This time its the invalid account or password error.
05/07/2009 03:37 Belth#7
Are you sure it's getting all the characters? Even typing manually flash log in seems slow on receiving input. Try putting a delay in between characters.
05/07/2009 04:33 lazlo#8
Yes. It plainly prints out the account, and there are exactly enough stars in the password box. If I check the memory location, it is empty, and loggin in obviously does not work.

If you scroll up you will see that I have a 200ms delay between down and up clicks.
05/07/2009 05:26 clintonselke#9
ok...

what about

PostMessage hUsernameTextbox,WM_SETTEXT,NULL,(LPARAM)pcText
PostMessage hPasswordTextbox,WM_SETTEXT,NULL,(LPARAM)pcText
?

However to requires the handles to the username & password text boxes. I'll look up how to do this.

Edit: ok, FindWindowEx() function can get the handles for the username and password boxes.

HWND FindWindowEx(
HWND hwndParent,
HWND hwndChildAfter,
LPCTSTR lpszClass,
LPCTSTR lpszWindow
);

so we have

hUsernameTextbox = FindWindowEx(FlashWindow, NULL, NULL, "LOGINPASS")
hPasswordTextbox = FindWindowEx(FlashWindow, NULL, NULL, "LOGINUSER")

im not 100% sure yet of these.

Edit:
Quote:
Originally Posted by lazlo View Post
I tried that as well. I get the same result. With the WM_CHAR though, I am not sure about the lParam. I have set it up like this:
Code:
        PostMessage FlashWindow, WndMsg.WM_KEYDOWN, &H44, 0
        Sleep 200
        PostMessage FlashWindow, WndMsg.WM_KEYUP, 0, 0
        Sleep 200
I have tried using the vk constants and the vbkey to no avail. No matter what I do, I get the same results, or it just doesn't work.
also for lparam for WM_KEYDOWN & WM_KEYUP can be found from here
[Only registered and activated users can see links. Click Here To Register...]

Note: Also for WM_KEYUP, u need to specify which key was released... and if there are capital letters in ur username or password, then u will need to send a WM_KEYDOWN for shift, then a WM_KEYDOWN for ur letter, then a WM_KEYUP for ur letter, then a WM_KEYUP for ur shift.

Edit:
There is also a SendKeys() function in vb that is pretty much exactly the same as the one in autoit (i didn't know about it). It might be an easier way than posting WM_KEYDOWN & WM_KEYUP events.
05/07/2009 16:51 lazlo#10
ok from the top...

the flashwindow (class name "MacromediaFlashPlayerActiveX") does not have any child windows to find. If you use spy++, you will see that it has no child windows.

the FindWindowEX would be setup as such:
Code:
hUserNameTextbox = FindWindowEX(FlashWindow,0&,vbnullstring,"LOGINUSER")
Which returns a zero. Where did you derive "LOGINUSER", or was this just a placeholder?

As far as the keydown and key up events, if I declare the key in the key up it posts the character 2 times in the textbox. I have tried it many ways, and it doesn't work with anything I do.
I have hard coded one account and pass into my routine until I have this issue resolved. After I get it loggin in properly, I will create the routine to convert the text from a textbox and input it into its respective place in the client.

to use sendkeys the textbox must have focus and must be the top level window. you cannot use it on a background window. It is also does not work very well, and most programmers stay away from it, probably why you haven't heard of it before now. For the types of programs that we are writing, it is uselss.