Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


SendKeys in VBScript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1327
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> SendKeys in VBScript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 SendKeys in VBScript - 9/7/2004 12:12:26 AM   
  Ax

 

Posts: 2
Score: 0
Joined: 9/7/2004
From: United Kingdom
Status: offline
Hi,

I'm having some trouble with the SendKeys statement in a pre-.Net version of VBScript, AFAIK version 6. According to the MSDN v6 help files, I should be using the following code to send a TAB character:

SendKeys "{TAB}", True

However, when I run my code this throws an Error 13: Type mismatch: 'SendKeys'
Microsoft VBScript runtime error

The MSDN website appears only to list code examples for VBScript.Net.

Anybody know what I'm doing wrong?

TIA
Ax

_____________________________

I'm not a naturally cruel person, but when I see a muppet I can't help but pull its strings
 
 
Post #: 1
 
 Re: SendKeys in VBScript - 9/7/2004 12:21:11 AM   
  devguy

 

Posts: 15
Score: 0
Joined: 7/31/2004
From: USA
Status: offline
In VBScript there is no 2nd parm for sendkeys and it is a method of WScript.Shell - it should read...

WSH = WScript.CreateObject("WScript.Shell")
WSH.SendKeys "{TAB}"

You can find more information at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthsendkeys.asp

(in reply to Ax)
 
 
Post #: 2
 
 Re: SendKeys in VBScript - 9/7/2004 12:43:43 AM   
  Ax

 

Posts: 2
Score: 0
Joined: 9/7/2004
From: United Kingdom
Status: offline
Many thanks, I found that page before but when I came across problems I assumed I was looking at the wrong version.

Using your code, I get an error 424 - Object Required: 'WScript', yet according to the MS help page on WScript ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsObjWScript.asp ) I should never need to instantiate the WScript object - it should always be available.

Am I missing something?

Can you help?
Ax

(in reply to Ax)
 
 
Post #: 3
 
 Re: SendKeys in VBScript - 9/9/2004 12:26:25 AM   
  devguy

 

Posts: 15
Score: 0
Joined: 7/31/2004
From: USA
Status: offline
Sorry, the code should have used the SET statement as so:

Set WSH = WScript.CreateObject("WScript.Shell")
WSH.SendKeys "{TAB}"

The WScript object is available, however, you need to create a reference to the Shell to use SendKeys.

(in reply to Ax)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> SendKeys in VBScript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts