GetAsyncKeyState not working with Right Click

GetAsyncKeyState not working with Right Click

Anonymous
Not applicable
816 Views
1 Reply
Message 1 of 2

GetAsyncKeyState not working with Right Click

Anonymous
Not applicable
I thought this used to work
Now it doesn't seem to
What am I forgetting?

'(in AutoCad vba) but I should think vb would be similar except for the
KeyCodeConstants.vbKeyRButton reference ( = 2)

Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
Integer
Private Const VK_RMC = KeyCodeConstants.vbKeyRButton

Public Function UserRightClicked() As Boolean
If (0 > GetAsyncKeyState(VK_RMC)) Then UserRightClicked = True
End Function

by doesn't seem to work, I mean when used in an error trap it says I didn't
hit right click when I did!
eg

On Error GoTo ErrCtl
....ask for selection from user
oDoc.Utility.GetEntity oEnt, vpt, "Pick text or block "

... if user hits right click selection fails with error sending us to ErrCtl
... I should get msgBox "right" but I don't....

ErrCtl:
If UserRightClicked Then
MsgBox"Right"
Else
MsgBox"Nope"
End if
0 Likes
817 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
"MP" wrote in message
news:5642331@discussion.autodesk.com...
I thought this used to work

'ok this seems to work in limited testing
'in the calling sub I need to hit GetAsyncKeyState to clear the value before
trying the line that could throw the error I'm trying to catch
'but that means I need to define GetAsyncKeyState in every scope I want to
use the test, or make it public in the .bas mod???
'is there a right way to do this?
:-)

'------------
Sub Main()
'initialize GetAsyncKeyState
Call GetAsyncKeyState(anyInteger)

On Error Resume Next' just for this example
oDoc.Utility.GetEntity oEnt, vpt, "Pick text or block"
If Err Then
If UserRightClicked Then
MsgBox "Right"
etc
'--------------

'in .Bas mod
Private Const VK_RBUTTON As Long = &H2&
Public Function UserRightClicked() As Boolean
If GetAsyncKeyState(VK_RBUTTON) = 1 Then UserRightClicked = True
End Function
0 Likes