提交新建内容
This commit is contained in:
58
order_executor.ahk
Normal file
58
order_executor.ahk
Normal file
@@ -0,0 +1,58 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user