home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Key Send"
- ClientHeight = 1845
- ClientLeft = 1170
- ClientTop = 1545
- ClientWidth = 2715
- Height = 2280
- Icon = KEYSND.FRX:0000
- Left = 1095
- LinkTopic = "Form1"
- ScaleHeight = 1845
- ScaleWidth = 2715
- Top = 1185
- Width = 2865
- Begin ccSubClass SubClass1
- Left = 600
- Messages = KEYSND.FRX:0302
- Top = 1320
- End
- Begin ccHookKbd HookKbd1
- Keys = KEYSND.FRX:0706
- Left = 120
- Monitor = 1 'All Tasks
- Top = 1320
- End
- Begin Label Label1
- Caption = "While this program is running, the backslash key puts the letter to the left of the cursor into the clipboard. See keysnd.txt."
- Height = 1095
- Left = 120
- TabIndex = 0
- Top = 0
- Width = 2535
- End
- Sub HookKbd1_KbdHook (keycode As Integer, keystate As Long, shiftstate As Integer, discard As Integer)
- ' The SbcKbd control is set to intercept the
- ' backslash ("\") key.
- ' First, make sure the key is discarded.
- discard = True
- ' SbcKbd fires events when the key is pressed and
- ' when the key is released. Ignore any event caused
- ' by the key being released.
- If keystate And &H80000000 Then GoTo Bye:
- ' There might be multiple events per keypress. Turn
- ' off the SbcKbd control while one event is handled.
- HookKbd1.Enabled = False
- ' Perform the correct action according to which key
- ' was pressed.
- Select Case keycode
- Case 220 ' the keycode for backslash
- ' The actual act of copying the last key into
- ' the clipboard takes too long to be done here.
- ' Instead, the Sbc PostEvent property is set,
- ' telling the Sbc control to send itself a
- ' delayed message. It will be safe to do the
- ' time intensive stuff then.
- SubClass1.PostEvent = 1
- End Select
- End Sub
- Sub SubClass1_DelayedEvent (lvalue As Long)
- ' Here is where the time-intensive part of the response
- ' to a message can be implemented.
- ' First, check what value was put into the PostEvent
- ' message, and react accordingly.
- If (lvalue = 1) Then
- ' Select the character to highlight using the
- ' standard Windows keyboard shortcut.
- SendKeys "+{left 1}"
- ' Copy selected text to clipboard using another
- ' standard Windows keyboard shortcut.
- SendKeys "^c"
- ' Turn the SbcKbd control back on, now that we are
- ' finished here.
- HookKbd1.Enabled = True
- End If
- End Sub
-