Sendkeys!

Iniciado por Xhom, 12 Septiembre 2015, 20:20 PM

0 Miembros y 1 Visitante están viendo este tema.

Xhom

Buenas tardes, quería preguntarles algo yo tengo este código que recién lo hice quería saber si estaba bien mi intención era que yo al Apretar una vez el numero 1 empiece hacer la pulsación : "{ENTER}" + "{ }" + "{ENTER}" y cuando vuelvo a apretarlo deja de hacerla.


Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKey1) Then
Timer1.Enabled = True
SendKeys "{ENTER}" + "{ }" + "{ENTER}"
End If
End Sub
Private Sub Timer2_Timer()
If GetAsyncKeyState(vbKey1) Then
Timer3.Enabled = False
End If
End Sub

Con este codigo lo que hice fue que al apretar la tecla 1

hago "ENTER ESPACIO ENTER" pero que no sigo como hago para que continue hasta que yo vuelva apretar el 1

otra vez.

Miseryk

Podés hacer que en el Timer1 checkée el tema de tomar la tecla apretada y en el 2do que haga la acción:

Código (vb) [Seleccionar]

Option Explicit

Dim bFlagKey1 As Boolean

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Long

Private Sub Form_Load()
bFlagKey1 = False

Timer1.Interval = 1
Timer1.Enabled = True

Timer2.Interval = 1000
Timer2.Enabled = True
End Sub

Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKey1) And 1 Then
    bFlagKey1 = Not bFlagKey1
End If
End Sub

Private Sub Timer2_Timer()
If bFlagKey1 Then
    SendKeys "{ENTER}" + "{ }" + "{ENTER}"
End If
End Sub
Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It's never too late to change our luck
So, don't let them steal your light
Don't let them break your stride
There is light on the other side
And you'll see all the raindrops falling behind
Make it out tonight
it's a revolution

CL!!!