473,490 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get Focus to window using VB script and SendKeys

3 New Member
Hello Experts,
I am working on automating a login to a webpage using SendKeys. The problem I am having is that I am trying to figure out how to get the Internet window in Focus so that way it can run the commands and not keep looping. My code is below:

Thanks,
Steve

Expand|Select|Wrap|Line Numbers
  1. Set IE = CreateObject("InternetExplorer.Application") 
  2. set WshShell = WScript.CreateObject("WScript.Shell")
  3. IE.Navigate "http://www.WebsiteName.com"
  4. IE.Visible = True
  5. Wscript.Sleep 6000 
  6. IE.Document.All.Item("email").Value = "UserName" 
  7. IE.Document.All.Item("pass").Value = "Password"
  8. WshShell.SendKeys "{TAB}"
  9. WshShell.SendKeys "{TAB}"  
  10. WshShell.SendKeys "{ENTER}"
Oct 12 '12 #1
4 4676
Rabbit
12,516 Recognized Expert Moderator MVP
What is the tab tab enter for? Is that to submit the form? You can use IE.Document.forms(0).submit() where 0 is the index of the form. In this case, it will submit the first form. If it's not the first form, you'll just have to find the correct index.
Oct 12 '12 #2
Unknown90
3 New Member
The tab tab enter was to submit the information to the webpage and login. It took two tabs from the password field to login.btn so thats why they were in there.
Oct 13 '12 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Yeah, you don't need to do that. You can just use the method in my post instead. It's more reliable.
Oct 13 '12 #4
Unknown90
3 New Member
Ok great. Thank you for your help.
Oct 13 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
37969
by: Shang Wenbin | last post by:
Hi, When I want to close the current window using window.close() in IE6.0, there will be a confirm box that: The web page you are viewing is trying to close the window. Do you want to close this...
4
34830
by: GrantS | last post by:
I am having a problem closing a popup window opened modally. When I try to close the window (when the user hits save button and the data has been processed), the Popup window opens as a full screen...
4
8057
by: trinity | last post by:
I am wondering if it is possible to accept and close the active window using its handle. I already have the handle using getActiveWindow(). I need to be able to click on the "yes" button to...
1
1520
by: Ken | last post by:
Is there a way to show a popup window using code behind in VB? Partial java script code: Open('htmpage.html')
1
2116
by: Bill Borg | last post by:
I have a simple chat application. "Host" program has a timer and listens for new requests for chat. The host user will typically minimize that window when there's nothing happening, but I'd like to...
1
9348
by: Max | last post by:
Hi, I am trying to paste text in a console window using SendKeys and the Clipboard (I am using Windows XP SP2 and .NET 1.1). Here is the code (I have a form with two edit boxes, DosTitle in...
3
4523
by: dibakar | last post by:
Hello I want to open a window using Window.showModalDialog once i click inside of a TextBox.And that window need to come just under the TextBox,so that it seems to a same control. So,what...
2
3179
by: Ralf | last post by:
Using .NET 1.1, vb code behind. I have a project and I have been opening new windows throughout it. I need them opened on top of the parent, and be able to minimize or go back to the parent if...
7
3321
by: tapanreddy | last post by:
I am looking to perform an action when we close the window using the close tab at the top of the screen. I know how to do it using a close button but I was wondering if there is way to achieve the...
5
2555
by: kalyangvd | last post by:
Hi Guys, I am trying to get the Field Id from the Parent Window in the pop up window using window.opener ex: var var1 = window.opener.document.getElementById("text1").value; ...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.