Missing movements from kernel32?

A

Andoni

Many Thanks in advance!

I am doing a game.
My game movement comes from:

2 DLL such as:
Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVa
nVirtKey As Long) As Integer
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

and from this Macro:

Sub Mymacro()
Do
Sleep 100
Select Case KeyPressed
Case GetAsyncKeyState(vbKeyEscape): End
'Case GetAsyncKeyState(vbKeyDown): Move_Down
Case GetAsyncKeyState(vbKeyRight): Move_Right
Case GetAsyncKeyState(vbKeyUp): Mov_Change
Case GetAsyncKeyState(vbKeyLeft): Move_Left
Case Else: Move_Down
End Select
DoEvents
Loop
end sub


my problem:



1) When my macro is running, I may move two times to the left and th
macro named "Mymacro" sometimes only takes one move, so I am missin
movement/s.

What am I doing Wrong
 
K

keepITcool

The Sleep function suspends the execution of the current thread for a
specified interval.

Use SetTimer/KillTimer iso sleep.

ApiGuide (3.7) has a perfect example called Key Spy.
d/l from http:AllApi.net

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Andoni wrote :
 
R

Rob van Gelder

I've seen Pacman built in Excel using that API.

Do a google search for: pacman excel
It's a Japanese site, but the download is easy enough to find.

Very impressive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top