自己的文件,传到公司内的,有时间整理下分享,vb托盘,关进程,鼠标点击和移动等

前端之家收集整理的这篇文章主要介绍了自己的文件,传到公司内的,有时间整理下分享,vb托盘,关进程,鼠标点击和移动等前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long,ByVal y As Long) As Long Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long,ByVal dx As Long,ByVal dy As Long,ByVal cButtons As Long,ByVal dwExtraInfo As Long) Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String,ByVal lpWindowName As String) As Long Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long 'Private Declare Function SetFocusAPI& Lib "user32" Alias "SetFocus" (ByVal Hwnd As Long) 'Private Declare Function ScreenToClient Lib "user32" (ByVal Hwnd As Long,lpPoint As POINTAPI) As Long 'Private Declare Function ClientToScreen Lib "user32" (ByVal Hwnd As Long,lpPoint As POINTAPI) As Long 'Private Declare Function GetWindowRect Lib "user32" (ByVal Hwnd As Long,lpRect As RECT) As Long 'Private Function GetDesktopWindowRect(Hwnd As Long,Rct As RECT,MousePos As POINTAPI) As Boolean Private Const MOUSEEVENTF_LEFTDOWN = &H2 Private Const MOUSEEVENTF_LEFTUP = &H4 Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long,wndRect As RECT) As Long Private Type RECT x As Long y As Long Right As Long Bottom As Long End Type Dim ActiveWindowRECT As RECT Dim ActiveWindowHwnd As Long Private Sub Command1_Click() Dim tWnd As Long tWnd = FindWindow(vbNullString,"PP助手 (1.0.6.4,Beta)") '找到父窗口句柄 'ClientToScreen tWnd,Point(200,200) SetForegroundWindow tWnd '激活窗口 GetWindowRect tWnd,ActiveWindowRECT 'SetActiveWindow tWnd 'SetFocusAPI& tWnd Debug.Print ActiveWindowRECT.x 'text1为X坐标 Debug.Print ActiveWindowRECT.y 'text2为Y坐标 AutoPressMouse ActiveWindowRECT.x + 100,ActiveWindowRECT.y + 172 '鼠标点击 'Sleep 3000 '387 374 'AutoPressMouse 165,254 End Sub Private Sub AutoPressMouse(x As Long,y As Long) SetCursorPos x,y ' mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP,0 mouse_event MOUSEEVENTF_LEFTDOWN,0 mouse_event MOUSEEVENTF_LEFTUP,0 End Sub Private Sub Command2_Click() ActiveWindowHwnd = GetForegroundWindow GetWindowRect ActiveWindowHwnd,ActiveWindowRECT Debug.Print ActiveWindowRECT.x 'text1为X坐标 Debug.Print ActiveWindowRECT.y 'text2为Y坐标 ' Dim Rects As RECT,ExecuteValue As Boolean ' Dim MousePoint As POINTAPI ' ExecuteValue = GetDesktopWindowRect(Command2.Hwnd,Rects,MousePoint) ' Debug.Print "ExecuteValue=" & ExecuteValue ' Debug.Print "Rects.Top=" & Rects.Top ' Debug.Print "Rects.Left=" & Rects.Left ' Debug.Print "Rect.Bottom=" & Rects.Bottom ' Debug.Print "Rect.Right=" & Rects.Right ' Debug.Print "MousePoint.X= " & MousePoint.X ' Debug.Print "MousePoint.Y=" & MousePoint.Y End Sub

猜你在找的VB相关文章