|
-
Jun 22nd, 2000, 10:27 PM
#1
Thread Starter
Lively Member
Does anyone know how to make the computer press a key without you toughing the keyboard when you click on a button?
Exp: you click a button and the computer presses the print screen key
-
Jun 22nd, 2000, 10:46 PM
#2
Lively Member
Use SendKeys, eg:
SendKeys("{PRTSC}")
-
Jun 22nd, 2000, 10:46 PM
#3
Junior Member
You can use the SendKeys function to simulate keystrokes, however you can't use SendKeys to operate the PrintScreen key for any application! If this is what you are trying to achieve, you might have to think about using the clipboard or some other way, if your example was just an example and you need to know about SendKeys, let me know.
We watch in reverence as Narcissus is turned to a flower.
-
Jun 22nd, 2000, 10:49 PM
#4
Thread Starter
Lively Member
sendkeys
tell me more about sendkeys
-
Jun 22nd, 2000, 11:03 PM
#5
Junior Member
You can use SendKeys to send key strokes to an application, for example if you were to create a Microsoft Word object and then activated a new document, you could write text to the document like this:
SendKeys "Dear Sir,"
It can be very useful, if you have MSDN help look it up if not let me know what you want to do and I will give you a solution.
We watch in reverence as Narcissus is turned to a flower.
-
Jun 23rd, 2000, 12:53 AM
#6
PowerPoster
You also use the keybd_event API function istead of Sendkeys function.
-
Jun 23rd, 2000, 02:43 AM
#7
There are some keys that you can not differenciate such as Left Ctrl, Right Ctrl, Left Shift and Right Shift. For this, you can use DirectInput.
-
Jun 23rd, 2000, 02:50 AM
#8
PowerPoster
With this code I can detect the Left/Right Shift and Left/Right Control key event
Code:
Option Explicit
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_LCONTROL = &HA2
Private Const VK_LSHIFT = &HA0
Private Const VK_RSHIFT = &HA1
Private Const VK_RCONTROL = &HA3
Private Sub Timer1_Timer()
If GetKeyState(VK_LSHIFT) < 0 Then
MsgBox "L_SHIFT"
ElseIf GetKeyState(VK_RSHIFT) < 0 Then
MsgBox "R_SHIFT"
ElseIf GetKeyState(VK_LCONTROL) < 0 Then
MsgBox "L_Ctrl"
ElseIf GetKeyState(VK_RCONTROL) < 0 Then
MsgBox "R_Ctrl"
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|