Files
real_view/order_executor.ahk
2025-07-28 12:15:45 +08:00

58 lines
1.3 KiB
AutoHotkey
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
DetectHiddenWindows, On
SetTitleMatchMode, 2
; 获取命令行参数
param1 = %1%
if (param1 = "click") {
x := %2%
y := %3%
MouseMove, x, y
Click
} else if (param1 = "image_click") {
; 图像识别点击功能
imagePath := %2%
winTitle := %3%
confidence := %4%
; 设置搜索区域
if (winTitle != "") {
WinGet, hwnd, ID, %winTitle%
if (!hwnd) {
ExitApp, 1 ; 未找到窗口,返回错误
}
WinGetPos, winX, winY, winW, winH, ahk_id %hwnd%
searchX := winX
searchY := winY
searchW := winW
searchH := winH
} else {
; 全屏搜索
searchX := 0
searchY := 0
searchW := A_ScreenWidth
searchH := A_ScreenHeight
}
; 使用ImageSearch进行图像识别
ImageSearch, foundX, foundY, searchX, searchY, searchX+searchW, searchY+searchH, *%confidence% %imagePath%
if (ErrorLevel = 0) {
; 找到图像,计算中心点并点击
centerX := foundX
centerY := foundY
MouseMove, centerX, centerY
Click
ExitApp, 0 ; 成功返回0
} else {
ExitApp, 1 ; 未找到图像,返回错误
}
} else if (param1 = "type") {
Send, %2%
} else if (param1 = "press") {
Send, {%2%}
}
ExitApp