meyerforhire Posted December 30, 2011 Posted December 30, 2011 I am working on a routine that, at one point, goes into a Do loop and reacts to keystroke input via the GetAsyncKeystroke API. The routine looks at the arrow keys and a couple others and translates those keystrokes into activating flip and angle states of the dynamic block selected--giving the user and interactive tool for block manipulation. Anyway, the issue I'm having is that when the loop is complete, all of the keystrokes pressed while in the loop come rushing into the command line. I've been very careful to choose keys for the routine which do not have a command or shortcut associated with them. However, the UP arrow key is the kicker. I would like to keep it in the routine because it's obvious when using the others. Plus, even if I don't use it, I'm sure users will still hit it while using the other arrow keys. What I would like to be able to do, is prevent all of those keystrokes from going back into the command line when the sub is complete. I've tried using the SetKeyboardState API after each keystroke to try to cover my tracks. But, it doesn't do anything. My guess is that there is some keystroke queue that needs to be cleared prior to exiting the sub. Does anyone know if it exists and, if so, how to clear it? If it doesn't exist, is there some Acad variable I can turn off? Is there a system variable, etc.....? I've briefly looked at keystroke hooks, but they seem awfully involved and complicated and I'm not even sure if it will do what I want. Any help?????? Oh, and yes I know, I should quit using vba for .NET.....I know. Also, I have no interest in converting my code into lisp. I can use lisp to do some very basic tasks. I could use lisp to set a variable if need be, but I don't want to go "all out" with it. Thanks in advance. Here's a snippet of the code: Do U = GetAsyncKeyState(VK_UP) D = GetAsyncKeyState(VK_DOWN) L = GetAsyncKeyState(VK_LEFT) R = GetAsyncKeyState(VK_RIGHT) A = GetAsyncKeyState(VK_RCONTROL) 'Ret = GetAsyncKeyState(VK_RETURN) 'Space = GetAsyncKeyState(VK_SPACE) S = GetAsyncKeyState(VK_RSHIFT) If (Rot >= 0 And Rot <= 45) Or (Rot >= 135 And Rot <= 225) Or Rot >= 315 Then If HasH And (U < 0 Or D < 0) Then Set objDyn = DynProps(h) If Hflip = 0 Then objDyn.Value = 1 objRef.Update objRef.Highlight True Exit Do Else objDyn.Value = 0 objRef.Update objRef.Highlight True Exit Do End If ElseIf HasV And (R < 0 Or L < 0) Then Set objDyn = DynProps(v) If Vflip = 0 Then objDyn.Value = 1 objRef.Update objRef.Highlight True Exit Do Else objDyn.Value = 0 objRef.Update objRef.Highlight True Exit Do End If ElseIf A < 0 And HasRot Then Set objDyn = DynProps(t) objDyn.Value = Rad - (¶ / 2) objRef.Update objRef.Highlight True Exit Do ElseIf S < 0 Then 'Ret < 0 Or Space < 0 Then Done = True Exit Do End If Else If HasV And (U < 0 Or D < 0) Then Set objDyn = DynProps(v) If Vflip = 0 Then objDyn.Value = 1 objRef.Update objRef.Highlight True Exit Do Else objDyn.Value = 0 objRef.Update objRef.Highlight True Exit Do End If ElseIf HasH And (R < 0 Or L < 0) Then Set objDyn = DynProps(h) If Hflip = 0 Then objDyn.Value = 1 objRef.Update objRef.Highlight True Exit Do Else objDyn.Value = 0 objRef.Update objRef.Highlight True Exit Do End If ElseIf A < 0 And HasRot Then Set objDyn = DynProps(t) objDyn.Value = Rad - (¶ / 2) objRef.Update objRef.Highlight True Exit Do ElseIf S < 0 Then 'Ret < 0 Or Space < 0 Then Done = True Exit Do End If End If Loop Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.