Visual Basic Explorer
Visual Basic Explorer
 Navigation
 Home


 Coding
 Source Code

 FAQ Center

 VB Tips

 Downloads

 ToolBox

 Tutorials

 VB Games

 VB News

 VB Award

 VB Forums



 Affiliates
 Planet Source Code

 Rent a Coder

 DirectX4VB


 Misc
 Search

 Feedback

 Advertise

 About


Need to hire
a VB coder?

Please support our sponsor:

 Home 
 Site Map 
 Forums 
 News 
 Feedback 

 

Q. How do I send keystrokes to Windows?

 
I have a basic familiarity with sendkeys, but I can`t
figure out how to send a CTRL+ALT+anyothercharacter to
Windows with VB3. If this can be done, how?

 
A. You can send CTRL + ALT +, say, X with:

 
Sendkeys "^%X"

 
The hard part is making sure whatever part of Windows
you want to contact is active. To do that, you will need
the Shell function, the AppActivate statement or both.

The following comes directly from the on-line help in VB4:

------------------
This example uses the Shell function to run the Calculator
application included with Microsoft Windows; it then uses
the SendKeys statement to send keystrokes to add some numbers
and then quit the Calculator.

 
To see the example, paste it into a procedure, then run the
procedure. Because AppActivate changes the focus to the Calculator
application, you can`t single step through the code.

eturnValue = Shell("Calc.exe", 1)' Run Calculator.
AppActivate ReturnValue' Activate the Calculator.
For I = 1 To 100' Set up counting loop.
SendKeys I & "{+}", True
' Send keystrokes to Calculator
Next I' to add each value of I.
endKeys "=", True' Get grand total.
SendKeys "%{F4}", True
' Send ALT+F4 to close Calculator.
-----------
The above code should work in VB3 and above.

 
(16-Aug-98 Bob Walsh rlwalsh@capecod.net)


Downloads

In IE right-click and select 'Save Target As...' or in Netscape right-click and select 'Save Link As...'

 

View Plain Text View Plain Text
Download Demo Project Not Available
View Code Online Not Available





Home | About | What's New | Source Code | FAQ | Tips & Tricks | Downloads | ToolBox | Tutorials | Game Programming | VB Award | Search | VB Forums | Feedback | VBNews | Copyright & Disclaimer | Advertise | Privacy Policy |

Quick searches: Site Search | Advanced Site Search 

Copyright 2002 by Exhedra Solutions, Inc.
By using this site you agree to its terms and conditions
VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc.