Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 9th, 2006, 3:15 AM   #1
nivex
Newbie
 
Join Date: Apr 2006
Posts: 3
Rep Power: 0 nivex is on a distinguished road
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 If

My 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", 2

But 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.
nivex is offline   Reply With Quote
Old Apr 9th, 2006, 10:27 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 9th, 2006, 11:30 AM   #3
nivex
Newbie
 
Join Date: Apr 2006
Posts: 3
Rep Power: 0 nivex is on a distinguished road
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.
nivex is offline   Reply With Quote
Old Apr 10th, 2006, 1:16 AM   #4
nivex
Newbie
 
Join Date: Apr 2006
Posts: 3
Rep Power: 0 nivex is on a distinguished road
Fixed it. Simply added a Sleep function to allow SendKeys time to properly insert text where it belongs.
nivex is offline   Reply With Quote
Old Apr 10th, 2006, 6:56 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I was thinking about this last night and hit upon the same possible solution. Nice find.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:44 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC