autohotkey - Autohotkey - 函数参数中的函数名称
问题描述
我在将另一个函数中的参数作为参数传递函数时遇到问题。下面的代码:
MSG(text) {
MsgBox, %text%
return
}
clicker(X1,Y1,X2,Y2,IMGFILE,ErrorLvlTrue,ErrorLvlFalse) {
CoordMode, Mouse, Window
CoordMode, Pixel, Window
sleep 1000
ImageSearch,OutX1,OutY1,%X1%,%Y1%,%X2%,%Y2%,%IMGFILE%
if (ErrorLevel = 0) {
return ErrorLvlTrue
}
else {
return ErrorLvlFalse
}
}
clicker(0,0,1900,1000,"*20 image_file.bmp",MSG(OutX1),MSG(OutY1))
不管它是否找到图像,我都得到了 MSG() 函数调用。
解决方案
Global myCount
clicker(0, 0, 1900, 1000, "*20 image_file.bmp", MSG(OutX1), MSG(OutY1))
Return
MSG(text)
{
myCount ++
MsgBox % ""
. "This MSG function is executed earlier " myCount " times" "`n`n"
. "and Your text argument is -->" text "<--"
}
clicker(X1, Y1, X2, Y2, IMGFILE, ErrorLvlTrue, ErrorLvlFalse)
{
If FileExist(IMGFILE)
MsgBox % "OK. You have an img file"
Else
MsgBox % "Nop. You do not have an img file"
CoordMode, Mouse, Window
CoordMode, Pixel, Window
Sleep, 1000
ImageSearch, OutX1, OutY1, % X1, % Y1, % X2, % Y2, % IMGFILE
MsgBox % ""
. "Now your clicker function executed" "`n`n"
. "X1, Y1 (" X1 ", "Y1 ")`n`n"
. "X2, Y2 (" X2 ", "Y2 ")`n`n"
. "Image File is -->" ImgFile "<--`n`n"
. "Error Level is -->" ErrorLevel "<--" ; "2" means there was a problem
}
推荐阅读
- ruby-on-rails - 警告:不推荐对关系调用搜索
- c - 如何创建指向二叉树节点的链表?
- c++ - 我正在写一些代码,但出现了这个错误
- python - 如何从一组输入数字中找到具有最大除数的数字?
- asp.net-core - ASP.NET Core Identity 阻止用户使用相同的密码
- php - 如何颤动/飞镖将图像数据发送到 apache 服务器 php 文件
- sql - SQL group-n-result (count, max, group)
- import - 在 SAS 中导入 txt 文件
- angular - Angular 9 - 类型“void”上不存在属性“订阅”
- javascript - 谷歌地图:通过地理编码器将地址转换为坐标后获取方向