PublicClass Form1Class Form1 PrivateConst MOUSEEVENTF_LEFTDOWN =&H2 PrivateConst MOUSEEVENTF_LEFTUP =&H4 PrivateConst MOUSEEVENTF_MIDDLEDOWN =&H20 PrivateConst MOUSEEVENTF_MIDDLEUP =&H40 PrivateConst MOUSEEVENTF_RIGHTDOWN =&H8 PrivateConst MOUSEEVENTF_RIGHTUP =&H10 PrivateDeclareFunction SetCursorPos()Function SetCursorPos Lib"user32" (ByVal x As Int32, ByVal y As Int32) As Int32 PrivateDeclareSub mouse_event()Sub mouse_event Lib"user32" (ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) PrivateSub Button2_Click()Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim p As Point =Me.ReportViewer1.PointToScreen(Me.ReportViewer1.Location) '模拟右键 p.X +=320 System.Windows.Forms.Cursor.Position = p mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0) mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0) '页面设置的坐标 p.Y +=80 p.X +=10 System.Windows.Forms.Cursor.Position = p mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 'End If end class