Visual Basic.NET - Capturar tecla presiona

 
Vista:

Capturar tecla presiona

Publicado por Francisco Ramon Ordoñez Andrade (5 intervenciones) el 21/06/2017 19:48:55
Buen dia, necesito generar un archivo cuando se presione la tecla delete, es decir si se esta usando un programa y un usuario presiona delete se genere un bloc de notas o cualquier archivo, esto para llevar un control de cuantas veces se da delete, alguine tiene una idea,?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Hugo
Val: 50
Ha disminuido su posición en 5 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Capturar tecla presiona

Publicado por Hugo (91 intervenciones) el 22/06/2017 23:55:24
1
2
3
4
If (e.Key = Key.Delete) Then
    'Abre el notepad
    Process.Start("notepad.exe", "C:\nota.txt" )
End If


Visita: https://vbpuntonet.blogspot.mx
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Capturar tecla presiona

Publicado por Francisco Ramon Ordoñez Andrade (5 intervenciones) el 23/06/2017 00:17:39
este es mi codigo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
 
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If (GetAsyncKeyState(46)) Then
Dim sRenglon As String = Nothing
Dim strStreamW As Stream = Nothing
Dim strStreamWriter As StreamWriter = Nothing
Dim ContenidoArchivo As String = Nothing
' Donde guardamos los paths de los archivos que vamos a estar utilizando ..
Dim PathArchivo As String
Dim i As Integer
Try
 
If Directory.Exists("C:\Estadistica") = False Then ' si no existe la carpeta se crea
Directory.CreateDirectory("C:\Estadistica")
End If
 
Dim numero As New Random
 
Dim minumero As Integer = numero.Next(0, 1000000)
Windows.Forms.Cursor.Current = Cursors.WaitCursor
PathArchivo = "C:\Estadistica\" & minumero & ".txt" ' Se determina el nombre del archivo con la fecha actual
 
'verificamos si existe el archivo
 
If File.Exists(PathArchivo) Then
strStreamW = File.Open(PathArchivo, FileMode.Open) 'Abrimos el archivo
Else
strStreamW = File.Create(PathArchivo) ' lo creamos
End If
 
strStreamWriter = New StreamWriter(strStreamW, System.Text.Encoding.Default) ' tipo de codificacion para escritura
 
 
'escribimos en el archivo
 
strStreamWriter.WriteLine("1 reproduccion")
 
 
strStreamWriter.Close() ' cerramos
 
Catch ex As Exception
MsgBox("Error al Guardar la ingormacion en el archivo. " & ex.ToString, MsgBoxStyle.Critical, Application.ProductName)
strStreamWriter.Close() ' cerramos
End Try
End If
Dim counter = My.Computer.FileSystem.GetFiles("C:\Estadistica").Count
If counter <> 0 Then
'MsgBox(counter)
Me.cantidad.Text = counter
End If
 
 
End Sub
 
Private Sub FrmInicio_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 
Timer1.Start()
 
End Sub

lo que pretendo hacer en el es que cada vez que se presione la tecla Supr en cualquier parte del sistema operativo, se e cree un archivo en la carpeta estadistica, pero tengo un problema si yo tengo presionado la tecla se me creen varios, y quiero que al presionarla solo me cree uno, una idea o ejemplo)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar