; 1,2,7 10,
Process, Priority, , High
isStart := false
boxLine := 20
; function====================================================================================
SmoothMouseMove(x, y, steps=10, duration=100) {
; MouseGetPos, currentX, currentY
; startX := currentX
; startY := currentY
; stepX := (x - startX) / steps
; stepY := (y - startY) / steps
; sleepDuration := duration / steps
; MsgBox, %A_Index%
; Loop % steps {
; newX := Round(startX + stepX)
; newY := Round(startY + stepY)
; newX := (startX + stepX)
; newY := (startY + stepY)
; DllCall("SetCursorPos", "int", newX, "int", newY)
; Sleep sleepDuration
; }
DllCall("SetCursorPos", "int", x, "int", y)
}
getPosition2(){
targetColor := 0x806454 ; 目标颜色
gradientThreshold := 10 ; 渐变阈值
; 获取鼠标当前位置的颜色
MouseGetPos, mouseX, mouseY
PixelGetColor, currentColor, mouseX, mouseY
; 判断颜色是否在指定的范围内
if (abs(currentColor - targetColor) <= gradientThreshold) {
Click mouseX mouseY
ToolTip %mouseX% %mouseY%, 850,700,3
} else {
; ToolTip %OutputVarX% %OutputVarY%, 850,700,3
}
}
Return
getPosition(){
Click
; PixelSearch, OutputVarX, OutputVarY, 14, 101, 658, 404, "0x806466"
; PixelSearch, OutputVarX, OutputVarY, 250, 150, 500, 300, "0x806466" ,10
MouseGetPos, mouseX, mouseY
PixelSearch, OutputVarX, OutputVarY, mouseX, mouseY, mouseX, mouseY, "0xFC6466" ,50
; PixelSearch, OutputVarX, OutputVarY, mouseX-10, mouseY-10, mouseX+10, mouseY+10, "0xFC6466" ,50
; PixelSearch, OutputVarX, OutputVarY, mouseX-20, mouseY, mouseX+20, mouseY, "0xFC6466" ,50
if(OutputVarX>0 or OutputVarY>0){
; MouseMove, OutputVarX, OutputVarY, 1,
Click OutputVarX, OutputVarY
MouseMove, RandomNumber(), -10, 3, R
ToolTip %OutputVarX% %OutputVarY%, 850,700,3
; MsgBox, OutputVarX,OutputVarY
}
; Click OutputVarX,OutputVarY
; MsgBox, OutputVarX,OutputVarY
}
Return
RandomNumber()
{
Random, num, 0, 1 ; 随机生成 0 或 1
if (num == 0)
return 10
else
return -10
}
return
move(x,y){
step := 3
xstep := x/step
ystep := y/step
loop %step%{
DllCall("mouse_event", "UInt", 1, "UInt", Round(xstep), "UInt", Round(ystep), "UInt", 0, "UInt", 0)
Sleep, 10
}
}
return
; command=================================================================================
loopClick:
MouseGetPos, currentX, currentY
Click
; x:= currentX + RandomNumber()
; y:= currentY - 15
; x:= RandomNumber()
; y:= -15
x:= 0
y:= -15
move(x,y)
; SmoothMouseMove(x,y)
; MouseMove, x, y, 2
; DllCall("SetCursorPos", "int", x, "int", y)
; Send {MouseMove, 0, 20, 2, R}
; MouseMove, RandomNumber(), -10, 1, R
return
; key==============================================================================
F1::
MouseGetPos, mouseX, mouseY
PixelGetColor, color, mouseX, mouseY
step := 20
; 显示鼠标位置的坐标
ToolTip, 鼠标位置:X=%mouseX% Y=%mouseY% color=%color%, 300,300,1
; DllCall("SetCursorPos", "int", 100, "int", 100)
move(100,100)
Return
; 693,196
; 744,243
F2::
isStart := !isStart
; getPosition()
if (isStart){
SetTimer, getPosition, 1000
ToolTip, f2, 800, 960, 2
}else{
SetTimer, getPosition, off
ToolTip, , , , 2
}
Return
F3::
MouseGetPos, currentX, currentY
; MsgBox, %currentX%,%currentY%
DllCall("SetCursorPos", "int", currentX, "int", currentY)
; MsgBox, %currentX%,%currentY%
return
; SendMode, Play
; 1::
; ImageSearch, FoundX, FoundY, 800, 400, 1000, 600, C:\code\bg\klmfb.png
; MsgBox, FoundX, FoundY
; Return
; ~$*LButton::
; SetTimer , loopClick, 120
; ToolTip p, 800,960,7
; return
; LButton Up::
; SetTimer , loopClick, Off
; ToolTip,,,,7
; return
F12::
Reload
Return
F4::
Suspend
; if (A_IsSuspended=1)
; ToolTip,Suspend,929,129,10
; else if (A_IsSuspended=0)
; ToolTip,,,,10
Return
AHK学习记录
于 2024-03-28 16:03:17 首次发布
文章描述了一段自动化脚本,涉及鼠标位置计算、平滑移动、颜色匹配、点击操作和定时任务。它展示了如何使用DLL调用、鼠标事件和颜色阈值来控制鼠标动作,以实现屏幕上的精确操作。
616

被折叠的 条评论
为什么被折叠?



