Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Missing movements from kernel32?

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

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Missing movements from kernel32?



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 :

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" (ByVal
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 the
macro named "Mymacro" sometimes only takes one move, so I am missing
movement/s.

What am I doing Wrong?


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Missing movements from kernel32?

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.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Andoni " wrote in message
...
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" (ByVal
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 the
macro named "Mymacro" sometimes only takes one move, so I am missing
movement/s.

What am I doing Wrong?


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
tabbed movements alpineuser Excel Discussion (Misc queries) 2 September 8th 09 09:44 PM
formula and cell link movements wenrichards Excel Worksheet Functions 2 January 17th 05 09:36 AM
VBA occur error - kernel32.dll Judy[_4_] Excel Programming 1 August 20th 03 10:43 AM
KERNEL32.DLL error after running EXCEL Macro Dan[_16_] Excel Programming 0 July 23rd 03 08:15 PM


All times are GMT +1. The time now is 09:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"