For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > March 2006 > Automatize two keys-stokes?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Automatize two keys-stokes?
RE

2006-03-28, 6:56 pm

My son is asking if it is possible to program a program that pushes two
keys alternatively with 1 second delay when he is playing a game but has
to go and do other stuff? For example when he has to go and eat then he
wants the q-key be pushed and after 1 second the e-key and after 1
second the q-key and after 1 second the e-key and so on so the game he
is playing proceeds. How do I do that?





TedF

2006-03-29, 3:56 am

Add a timer to form1, and set interval to 1000
Then add this code to the form, run it and open notepad.

Option Explicit
Dim iqKey As Long
Private Sub Timer1_Timer()
If iqKey = 0 Then
iqKey = 1
DoEvents
SendKeys "{q}"
DoEvents
Else
iqKey = 0
DoEvents
SendKeys "{e}"
DoEvents
End If

End Sub



"RE" <rolfe@algonet.se> wrote in message
news:uxzfkzmUGHA.1564@TK2MSFTNGP11.phx.gbl...
> My son is asking if it is possible to program a program that pushes two
> keys alternatively with 1 second delay when he is playing a game but has
> to go and do other stuff? For example when he has to go and eat then he
> wants the q-key be pushed and after 1 second the e-key and after 1
> second the q-key and after 1 second the e-key and so on so the game he
> is playing proceeds. How do I do that?
>
>
>
>
>



RE

2006-03-29, 7:55 am

TedF,

I and my son are VERY grateful!!!!

Thank you!!!

Rolf and David

"TedF" <NoReply@xxxmsn.com> skrev i meddelandet
news:%23d$rlVuUGHA.5808@TK2MSFTNGP12.phx.gbl...
> Add a timer to form1, and set interval to 1000
> Then add this code to the form, run it and open notepad.
>
> Option Explicit
> Dim iqKey As Long
> Private Sub Timer1_Timer()
> If iqKey = 0 Then
> iqKey = 1
> DoEvents
> SendKeys "{q}"
> DoEvents
> Else
> iqKey = 0
> DoEvents
> SendKeys "{e}"
> DoEvents
> End If
>
> End Sub
>
>
>
> "RE" <rolfe@algonet.se> wrote in message
> news:uxzfkzmUGHA.1564@TK2MSFTNGP11.phx.gbl...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com