![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Posts: 3
Rep Power: 0
![]() |
Problem with SendKeys()
I'm making a project to enter my account name and password details for the game, Diablo II, and log me in. However, I'm having an issue with the SendKeys command.
I'll go ahead and paste the function (small), since it holds some strings you might be curious about. I've bolded the code that isn't working, and have left comments below the CODE so you can see what I'm having an issue with.
Dim lTop As Long, lLeft As Long, resX As Long, resY As Long
resX = Screen.Width / Screen.TwipsPerPixelX
resY = Screen.Height / Screen.TwipsPerPixelY
lTop = (resX - 800) / 2
lLeft = (resY - (620)) / 3
Call GetdhWnd
If Not DiablohWnd = 0 Then 'if hWnd exists in String DiablohWnd then proceed
Call MoveWindow(DiablohWnd, lTop, lLeft, 800, 630, 5) 'move diablo window to center of screen, above taskbar
Call SetCursorPos(470, 415) 'set cursor to Account Name
Call DblC(470, 415) 'double click Account Name field (textbox)
SendKeys "account" 'input Account Name
SendKeys "{TAB}" 'tab to password box, doesnt work. this is part of my problem
Call SetCursorPos(470, 465) 'set cursor to Password
Call DblC(470, 465) 'double click Password field (textbox)
SendKeys "password"
'sendkeys "{ENTER}" 'doesn't work
Call SetCursorPos(470, 545) 'set cursor to Log In
Call DblC(470, 545) 'Log in to the account
End IfMy problem is, when I use the SendKeys function, it crams everything I want inputed, into the account name field (textbox). My output should be: Account: account Password: Password However, it looks like this, Account: accountpassword Password: The SendKeys "{TAB}" isn't tabbing me into the next textbox. It does absolutely nothing. I've tried using
SendKeys "username"
SendKeys "{TAB}"
SendKeys "password", 2But it still puts all text in the account textbox. I'm stumped. I've looked for a couple hours to resolve this, but I've gotten nothing accomplished. Being a newbie sucks. I'd apperciate any help you generous guys n gals can provide for me. I hope I was very clear (am new to these forums, read the sticky for posting). Also, if you may, please detail your answer so I may understand it (I love commented code, since I'm still a newbie). To note: I have tried just getting the parent hWnd values of both text boxes, but, they aren't available for some reason. |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I take it the tab key works in-game normally?
I don't have an answer for you, but I can tell you why you can't find the control handles. They don't exist. The controls are most likely not actually controls, but simply pictures drawn onto the screen. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2006
Posts: 3
Rep Power: 0
![]() |
Yes, tab key works fine in-game. I just can't figure out a way to emulate it being pressed.
The tab key isn't my only issue. SendKeys is putting the text together, rather than in its seperate textboxes. I'll check back here later, going to work now. |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Apr 2006
Posts: 3
Rep Power: 0
![]() |
Fixed it. Simply added a Sleep function to allow SendKeys time to properly insert text where it belongs.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|