InPowerS.Net

 找回密碼
 註冊
搜索
查看: 1902|回復: 0

滑鼠移動到螢幕座標

[複製鏈接]
發表於 2008-12-25 22:52:10 | 顯示全部樓層 |閱讀模式
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
    Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Public Const WM_MOUSEMOVE = &H200
    Public Const WM_LBUTTONDOWN = &H201
    Public Const WM_LBUTTONUP = &H202
    Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)
    Public Declare Function CloseWindow Lib "user32" (ByVal hwnd As Integer) As Integer

    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As String, ByVal Source As String, ByVal Length As Integer)
    Private Function MAKELPARAM(ByVal wLow As Integer, ByVal wHigh As Integer) As Integer
        Dim Param(0 To 1) As Integer
        Param(0) = wLow
        Param(1) = wHigh
        CopyMemory(MAKELPARAM, Param(0), 4&)
    End Function
    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Call SetCursorPos(xp + 200, yp + 200) '滑鼠移動到螢幕座標 X,Y(單位是圖元
        '  mouse_event(MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        ' mouse_event(MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
        PostMessage(控制碼, WM_LBUTTONDOWN, 0, 0)    '模擬按一下
        PostMessage(控制碼, WM_LBUTTONUP, 0, 0)
        'PostMessage(控制碼, WM_MOUSEMOVE, (370), 300)
        PostMessage(控制碼, WM_LBUTTONDOWN, 0, MAKELPARAM(xp + 200, yp + 200))
        PostMessage(控制碼, WM_LBUTTONUP, 0, MAKELPARAM(xp + 200, yp + 200))
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

小黑屋|Archiver|手機版|InPowerS.Net

GMT+8, 2018-10-22 07:54

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表