elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Ayuda, SendKeys
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda, SendKeys  (Leído 3,365 veces)
sebah97

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Ayuda, SendKeys
« en: 10 Febrero 2010, 11:23 am »



Como Verán, lo que quiero hacer es que si en txtlog(label) el caption dice "Arriba" x ejemplo se presione VbKeyUp

Me dan Alguna idea o corregirme este código? (Se me Ocurrio a mi de esa Manera, pero no anda :S)

Código:

Código
  1. Const KEYEVENTF_KEYUP = &H2
  2. Const KEYEVENTF_EXTENDEDKEY = &H1
  3.  
  4.  
  5.  
  6. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
  7.    ByVal bScan As Byte, _
  8.    ByVal dwFlags As Long, _
  9.    ByVal dwExtraInfo As Long)
  10.  
  11. Sub Pulsar_Tecla(Tecla As Long)
  12.  
  13.    Call keybd_event(Tecla, 0, 0, 0)
  14.  
  15.    Call keybd_event(Tecla, 0, KEYEVENTF_KEYUP, 0)
  16.  
  17. End Sub
  18.  
  19. Private Sub AbajoT_Timer()
  20. Call Pulsar_Tecla(vbKeyDown)
  21. End Sub
  22.  
  23. Private Sub ArribaT_Timer()
  24. Call Pulsar_Tecla(vbKeyUp)
  25. End Sub
  26.  
  27. Private Sub bntListen_Click()
  28. On Error GoTo errorSub
  29.  
  30.    With Winsock1
  31.        .Close
  32.        .LocalPort = txtPort
  33.        .Listen
  34.    End With
  35.  
  36. Exit Sub
  37. errorSub:
  38. MsgBox "Error : " & Err.Description, vbCritical
  39. End Sub
  40.  
  41. Private Sub bntSend_Click()
  42. On Error GoTo errorSub
  43.  
  44.    Winsock1.SendData txtSend
  45.  
  46.    txtlog = txtlog & "Servidor : " & txtSend & vbCrLf
  47.    txtSend = ""
  48.  
  49. Exit Sub
  50. errorSub:
  51. MsgBox "Error : " & Err.Description
  52.  
  53. Winsock1_Close
  54. End Sub
  55.  
  56.  
  57. Private Sub DerechaT_Timer()
  58. Call Pulsar_Tecla(vbKeyRight)
  59. End Sub
  60.  
  61. Private Sub Form_Load()
  62.  
  63. Call bntListen_Click
  64.  
  65. AbajoT.Enabled = False
  66. ArribaT.Enabled = False
  67. DerechaT.Enabled = False
  68. IzquierdaT.Enabled = False
  69.  
  70. If txtlog.Caption = "Abajo" Then
  71. AbajoT.Enabled = True
  72. ArribaT.Enabled = False
  73. DerechaT.Enabled = False
  74. IzquierdaT.Enabled = False
  75. End If
  76.  
  77. If txtlog.Caption = "Arriba" Then
  78. AbajoT.Enabled = False
  79. ArribaT.Enabled = True
  80. DerechaT.Enabled = False
  81. IzquierdaT.Enabled = False
  82. End If
  83.  
  84. If txtlog.Caption = "Derecha" Then
  85. AbajoT.Enabled = False
  86. ArribaT.Enabled = False
  87. DerechaT.Enabled = True
  88. IzquierdaT.Enabled = False
  89. End If
  90.  
  91. If txtlog.Caption = "Izquierda" Then
  92. AbajoT.Enabled = False
  93. ArribaT.Enabled = False
  94. DerechaT.Enabled = False
  95. IzquierdaT.Enabled = True
  96. End If
  97.  
  98. End Sub
  99.  
  100. Private Sub IzquierdaT_Timer()
  101. Call Pulsar_Tecla(vbKeyLeft)
  102. End Sub
  103.  
  104. Private Sub Winsock1_Close()
  105.    ' Finaliza la conexión
  106.    Winsock1.Close
  107.  
  108.    txtlog = txtlog & "*** Desconectado" & vbCrLf
  109.  
  110. End Sub
  111.  
  112. Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
  113.  
  114.    If Winsock1.State <> sckClosed Then
  115.        Winsock1.Close ' close
  116.    End If
  117.  
  118.    Winsock1.Accept requestID
  119.  
  120.    txtlog = "Cliente conectado. IP : " & _
  121.              Winsock1.RemoteHostIP & vbCrLf
  122.  
  123.  
  124.  
  125. End Sub
  126.  
  127. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  128. Dim dat As String
  129.  
  130.    Winsock1.GetData dat, vbString
  131.    txtlog = dat & vbCrLf
  132.  
  133.  
  134.  
  135.  
  136. End Sub
  137.  
  138. ' cuando se produce un error lo envía
  139. ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  140. Private Sub Winsock1_Error(ByVal Number As Integer, _
  141.                           Description As String, _
  142.                           ByVal Scode As Long, _
  143.                           ByVal Source As String, _
  144.                           ByVal HelpFile As String, _
  145.                           ByVal HelpContext As Long, _
  146.                           CancelDisplay As Boolean)
  147.  
  148.    txtlog = txtlog & "*** Error : " & Description & vbCrLf
  149.  
  150.    Winsock1_Close
  151.  
  152. End Sub

Gracias de Antemano :)


En línea

Sm0kes

Desconectado Desconectado

Mensajes: 22



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #1 en: 11 Febrero 2010, 07:25 am »

en vez de usar too ese kodigo en timers yo pondria lo k haria dentro de este Sub

Código:
Private Sub Label1_Change()
   '######Codigo a ejecutar#######
End Sub

y kon respekto a lo de detectar k tekla k pulso xk no usas

Código:
Private Declare Function GetAsyncKeyState Lib "user32.dll" ( ByVal vKey As Long) As Long



En línea

sebah97

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #2 en: 12 Febrero 2010, 02:08 am »

Hola, Gracias x responder, pero no se como se usa el Evento Change() porfavor me explican? o algun manual o algo.

Gracias  :D
En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: Ayuda, SendKeys
« Respuesta #3 en: 12 Febrero 2010, 03:25 am »

.
El evento change como su nombre lo indica hace y se ejecuta su acción cuando y solo cuando el .caption en el caso de los label cambia. en el caso de los botones es lo mismo, listbox (propiedad text), , textbox (propiedad text), etc..

Sangrientas Lunas!¡.
.
En línea

The Dark Shadow is my passion.
sebah97

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #4 en: 12 Febrero 2010, 05:14 am »

y la sintaxis como sería ?

Así?

Private Sub Label1_Change(.caption= Izquierda)
   '######Codigo a ejecutar#######
End Sub

no tngo la menor idea yo :S

porque yo quiero q si el caption del label 1 diga Izquierda, se ejute la accion q yo quiero, no q se ejecute si el caption cambia, entienden?

En línea

Sm0kes

Desconectado Desconectado

Mensajes: 22



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #5 en: 12 Febrero 2010, 05:24 am »

jejeje ya te me tas confundiendo mucha mira aqui te hize un ejemplo

Código:
Private Sub Label1_Change()
    If Label1.Caption = "izquierda" Then
        MsgBox "Cambio a izquierda"
    ElseIf Label1.Caption = "derecha" Then
        MsgBox "Cambio a derecha"
    End If
End Sub
En línea

sebah97

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #6 en: 12 Febrero 2010, 05:41 am »

GRACiAS!!!!! me sirvio de mucho :D
En línea

Sm0kes

Desconectado Desconectado

Mensajes: 22



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #7 en: 12 Febrero 2010, 05:56 am »

jejeje de naa amigo te estaba complicando la vida teniendo el codigo k posteaste arriba xD ... Salu2
En línea

sebah97

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #8 en: 12 Febrero 2010, 06:21 am »

jaja x poco creaba una dll o.O
En línea

sebah97

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Re: Ayuda, SendKeys
« Respuesta #9 en: 12 Febrero 2010, 11:20 am »

Me surgio un problema :S

Yo puse asi miren (en el evento change de txtlog, qe es un label)

Código
  1. If txtlog.Caption = "Abajo" Then
  2. AbajoT.Enabled = True
  3. End if

Lo que AbajoT hace es:

Código
  1. Private Sub AbajoT_Timer()
  2. SendKeys ("{DOWN}")
  3. End Sub

Pero si dice caption de txtlog = Abajo , no pasa nada :S [Alguna solucion?]
« Última modificación: 12 Febrero 2010, 11:56 am por sebah97 » En línea

Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Ayuda] Simular un click del mause con sendkeys vbKeyLButton
Scripting
Flamer 3 4,901 Último mensaje 9 Marzo 2015, 20:52 pm
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines