返回正确的鼠标线问题
Issue returning proper mouse cords
在这个问题中调用setXTowerLocation(),退出消息框后出现一个消息框调用函数getXCords(),一旦它检测到它按下了getxCords,它就会不断扫描检查Lbutton的keyState () 函数 returns 鼠标线的 x 值,在返回并在消息框中显示 x 线之前,它又被设置为 setXTowerLocation() 函数中的全局变量。每次我 运行 它的消息框都是空白的,我已经测试了代码的各个方面,它们似乎都可以单独工作所以我相信这一定是语法错误?
结束消息框仅用于测试目的。提前致谢:)
SendMode Input
Global xTowerLocation =
setXTowerLocation()
MsgBox, 0, MessageBox, %xTowerLocation%
getxCords()
{
xCord =
Loop,
{
GetKeyState, state, Lbutton
if(state = "D")
{
MouseGetPos, xx, yy
xCord := %xx%
return
}
}
return xCord
}
setXTowerLocation() {
MsgBox, 0, MessageBox, Begin?
IfMsgBox OK
xTowerLocation := getxCords()
return
}
是的,xCord 引用了以内容(鼠标坐标)命名的变量的语法错误。修复 getxCords()
中的这两行,以便 xCord 保存变量 xx 的值,如下所示:
xCord := xx
return xCord
然后没有 xCord
之后 return
(在函数末尾)。
编辑:为了更有趣,将上面的 xCord
行制作如下:
xCord := "x= " . xx . " , y= " . yy
在这个问题中调用setXTowerLocation(),退出消息框后出现一个消息框调用函数getXCords(),一旦它检测到它按下了getxCords,它就会不断扫描检查Lbutton的keyState () 函数 returns 鼠标线的 x 值,在返回并在消息框中显示 x 线之前,它又被设置为 setXTowerLocation() 函数中的全局变量。每次我 运行 它的消息框都是空白的,我已经测试了代码的各个方面,它们似乎都可以单独工作所以我相信这一定是语法错误?
结束消息框仅用于测试目的。提前致谢:)
SendMode Input
Global xTowerLocation =
setXTowerLocation()
MsgBox, 0, MessageBox, %xTowerLocation%
getxCords()
{
xCord =
Loop,
{
GetKeyState, state, Lbutton
if(state = "D")
{
MouseGetPos, xx, yy
xCord := %xx%
return
}
}
return xCord
}
setXTowerLocation() {
MsgBox, 0, MessageBox, Begin?
IfMsgBox OK
xTowerLocation := getxCords()
return
}
是的,xCord 引用了以内容(鼠标坐标)命名的变量的语法错误。修复 getxCords()
中的这两行,以便 xCord 保存变量 xx 的值,如下所示:
xCord := xx
return xCord
然后没有 xCord
之后 return
(在函数末尾)。
编辑:为了更有趣,将上面的 xCord
行制作如下:
xCord := "x= " . xx . " , y= " . yy