- 帖子
- 218
- 主題
- 73
- 精華
- 0
- 積分
- 290
- 點名
- 0
- 作業系統
- WIN10
- 軟體版本
- Office2010
- 閱讀權限
- 20
- 性別
- 女
- 註冊時間
- 2014-5-19
- 最後登錄
- 2022-11-29
|
4#
發表於 2022-9-6 22:54
| 只看該作者
#If VBA7 Then
Private Declare PtrSafe Function GetPixel Lib "gdi32" (ByVal hdc As LongPtr, ByVal x As Long, ByVal y As Long) As Long
Private Declare PtrSafe Function GetCursorPos Lib "user32" (ByRef lpPoint As POINT) As LongPtr
Private Declare PtrSafe Function GetWindowDC Lib "user32" (ByVal hwnd As LongPtr) As LongPtr
#Else
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINT) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
#End If
Private Type POINT
x As Long
y As Long
End Type
Sub Picture1_Click()
Dim pLocation As POINT
Dim lColour As Long
Dim lDC As Variant
lDC = GetWindowDC(0)
Call GetCursorPos(pLocation)
lColour = GetPixel(lDC, pLocation.x, pLocation.y)
Range("a1").Interior.Color = lColour
End Sub
--------------------------------------------------------------------------------
以上是網路大神幫忙提供的滑鼠游標抓色程式碼,但我不知道要怎麼改成判斷滑鼠游標位置,如果抓到什麼顏色時,就往下一步進行,不知道有沒大神可以幫忙改改呢 |
|