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
Not Available
Not Available