Solved

VB6 SendKeys

Posted on 2011-03-19
4
800 Views
Last Modified: 2012-05-11
How do I get back to tab position #1 ie:

I want the 4th box to say "Hello":
    WebBrowser2.SetFocus
    SendKeys ("{Tab}")
    SendKeys ("{Tab}")
    SendKeys ("{Tab}")
    SendKeys ("Hello")

Then I want the 3rd box to say "World":
    WebBrowser2.SetFocus
    SendKeys ("{Tab}")
    SendKeys ("{Tab}")
    SendKeys ("World")
0
Comment
Question by:hrolsons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Accepted Solution

by:
kbirecki earned 500 total points
ID: 35173716
Can you use Shift-Tab to backup one field at a time:

 SendKeys ("+{Tab}")

"+" is the shift key.  Repeat that as many times as you need.  Does that work for you?
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35173758
-to simplify your codes, you can use for-loop:

 WebBrowser2.SetFocus
 For i = 1 to 3
    SendKeys ("{TAB}"), True
 Next i
 SendKeys "Hello"
 SendKeys ("+{TAB}")

and you might want to look at this example using keyboard event: http://www.freevbcode.com/ShowCode.Asp?ID=340
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 35174154
have you tried using the elements of the webbrowser control rather than sendkeys.  SendKeys is quite unreliable as it relies upon an application not losing focus or repainting.

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_25082070.html

http://vbcity.com/blogs/jatkinson/archive/2009/12/12/programmatically-entering-and-data-using-the-webbrowser-control.aspx

if you can look at the webpage source and post the relevant parts, we can help determine the elements you wish to reference and set them diagrammatically rather than using sendkeys.
0
 
LVL 4

Expert Comment

by:coolcurrent4u
ID: 35174894
if you want to write any of those words at a particular control, e.g textbox, you can call textbox1.setfocus() instead.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question