Developer, Former MVP, now at Microsoft - Best of 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
mouse_event
' Wrapper for mouse_event, performing click action on coordinates given Public Shared Sub PerformMouseClick(ByVal aX As Int32, ByVal aY As Int32, ByVal aForm As Control) Dim p As Point = aForm.PointToScreen(New Point(aX, aY)) Dim m1 As Int32 = (65535 \ Screen.PrimaryScreen.Bounds.Width) Dim m2 As Int32 = (65535 \ Screen.PrimaryScreen.Bounds.Height) Dim x As Int32 = m1 * p.X Dim y As Int32 = m2 * p.Y Win32Api.mouse_event(2 Or &H8000, x, y, 0, 0) Win32Api.mouse_event(4 Or &H8000, x, y, 0, 0) End Sub ' Button1 event handler. Simulates button click OR opening a main menu. Same principle applies for ToolBarButton Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PerformMouseClick(Button2.Left + 1, Button2.Top + 1, Me) 'performs click on other button 'PerformMouseClick(5, 5, Me) 'opens main menu on full screen WinCE app 'PerformMouseClick(Me.Left + 5, Me.Height + 5, Me) 'opens main menu on PPC app End Sub