滑鼠移動到該色點,點擊右鍵

繼上次學會GetPixel

我又遇到困難了!

請問各位大大!有什麼方式可以讓滑鼠游標,移動到

我要找的色點上面呢?然後點右鍵…

在按鍵精靈做得到!可是Visual Basic 6.0 的作法我不會!

我又不想用按鍵精靈。

所以想請教大大,可以敎我捏?

____________________________

在遊戲視窗裡,發現[紅點],移動到該紅色點上面,點下滑鼠右鍵!

____________________________

像這樣↑

已更新項目:

那...我要在該內容,添加滑鼠偏移量為50

要怎麼修改呢?

2 個已更新項目:

WJS大...

我找到了鎖定怪物該顏色,

但是該顏色不能使游標便成攻擊狀態…

需要再移過去。可是我想要適用所有怪物!

共同顏色就只有鎖定目標那種,是否有辦法在讓滑鼠自己移過去一點?

把游標便成攻擊狀態的圖示。。。

3 個已更新項目:

找到該色點>滑鼠移動到該色點上>點下右鍵

(這時,要判斷怪物有沒有死,要靠上方的紅色血條)

>如果上方紅色血條為紅色就繼續點右鍵>如果不是就按下空白鍵>

--------

我的邏輯很不通 = =

懇請幫忙

4 個已更新項目:

我知道...

可是我不知道要怎麼排程式碼 = ="

1 個解答

評分
  • W.J.S.
    Lv 7
    1 0 年前
    最佳解答

    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

    Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

    Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long

    Private Sub Command1_Click()

    Dim X As Long, Y As Long, dc As Long, i As Long

    dc = GetDC(0)

    i = 6 '一次跳6個像素以增加效率(請自行增減)

    For X = 0 To ScaleX(Screen.Width, 1, 3) Step i

    For Y = 0 To ScaleY(Screen.Height, 1, 3) Step i

    If GetPixel(dc, X, Y) = RGB(255, 0, 0) Then

    SetCursorPos X, Y

    Exit For

    End If

    Next

    Next

    ReleaseDC hwnd, dc

    End Sub

    2009-04-22 12:07:08 補充:

    忘了還要點擊右鍵!請先宣告

    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)

    Const MOUSEEVENTF_RIGHTDOWN = &H8

    Const MOUSEEVENTF_RIGHTUP = &H10

    2009-04-22 12:08:56 補充:

    然後將 SetCursorPos X, Y 改成:

    SetCursorPos X, Y

    mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 0&, 0&, 0&, 0&

    2009-04-22 14:21:27 補充:

    試試看在SetCursorPos X + ?, Y + ? 動手腳.

    2009-04-22 23:55:25 補充:

    你可用GetPixel去判斷血條是否為紅色,而GetPixel的座標就必須靠你自己去抓了,看當鎖定怪物該顏色時的xy跟血條的xy須加減多少.

還有問題?馬上發問,尋求解答。