参考一下:
Public Function ClickConfirm() As Boolean Dim objUtil As AcadUtility Dim varPnt As Variant Dim strPrmt As String On Error GoTo Err_Control ‘strPrmt = "Left click to confirm, right click to cancel" strPrmt = "鼠标左键确认,右键取消" Set objUtil = ThisDrawing.Utility varPnt = objUtil.GetPoint(Prompt:=strPrmt) 'No error? Then they "left clicked" (or typed a point on 'The command line. Meh. Users are crazy. ClickConfirm = True Exit_Here: Exit Function Err_Control: 'Debug.Print Err.Description; Err.Number Select Case Err.Number Case -2145320928 'Right click with command prompt or "Enter" key 'User input is a keyword Err.Clear Resume Exit_Here Case -2147352567 'User pressed escape or clicked a toolbar 'Method 'GetPoint' of object 'IAcadUtility' failed Err.Clear Resume Exit_Here Case Else Err.Clear Resume Exit_Here End Select End Function 功能 实现鼠标左键确认,右键取消功能 语法 ClickConfirm() 返回值 True为按了左键 |