AutoHotKey GUI按钮发送变量
问题描述:
我在AutoHotKey中有一个GUI菜单,我遇到了麻烦。 GUI有三个名为“红色”,“蓝色”和“绿色”的按钮。AutoHotKey GUI按钮发送变量
当用户点击说“红色”时,会发生一个动作。如果用户点击说“蓝色”,则会发生不同的动作。
循环以F4键启动,但不同的事情应循环,具体取决于按下哪个按钮:红色,蓝色或绿色。
这是剧本我到目前为止有:
Gui, Add, Tab, x366 y377 w-100 h-400 , Tab1
Gui, Add, Picture, x6 y7 w320 h90 , C:\IMAGEFILEHERE
Gui, Add, Text, x46 y147 w140 h40 , Spawning Team
Gui, Add, Button, x206 y117 w120 h20 , Red
Gui, Add, Button, x206 y147 w120 h20 , Blue
Gui, Add, Button, x206 y177 w120 h20 , Green
Gui, Show, x436 y230 h208 w336, SCRIPTNAME
Loop
{
If run =
{
sleep,250
continue
}
Else
{
if (Team = "Red") ; If Red is selected, run this part
{
ACTION1HERE
}
if (Team = "Blue") ; If Blue is selected, run this part
{
ACTION2HERE
}
if (Team = "Green") ; If Green is selected, run this part
{
ACTION3HERE
}
}
}
return
F4::
If run =
run = 1
Else
run =
return
ButtonRed:
Team = Red.
MsgBox The value in the variable named Team is %Team%.
Return
ButtonBlue:
Team = Blue.
MsgBox The value in the variable named Team is %Team%.
Return
ButtonGreen:
Team = Green.
MsgBox The value in the variable named Team is %Team%.
Return
的问题是,按下按钮没有被if语句检测。
任何帮助非常感谢!^_ ^我对AHK很新颖。
答
一个GRED,gBlue和gGreen标签添加到每个Add按钮,然后创建3个标签(去地址)
Gui, Add, Tab, x366 y377 w-100 h-400 , Tab1
Gui, Add, Picture, x6 y7 w320 h90 , C:\IMAGEFILEHERE
Gui, Add, Text, x46 y147 w140 h40 , Spawning Team
Gui, Add, Button, x206 y117 w120 h20 gRed, Red
Gui, Add, Button, x206 y147 w120 h20 gBlue, Blue
Gui, Add, Button, x206 y177 w120 h20 gGreen, Green
Gui, Show, x436 y230 h208 w336, SCRIPTNAME
Red:
MsgBox, ACTION1HERE
Return
Blue:
MsgBox, ACTION2HERE
Return
Green:
MsgBox, ACTION3HERE
Return
答
这个问题可能已经过时了,但我的回答也无妨......因为有人可能会偶然发现这个以及第一个无用的答案。
该循环可能会阻止较低的脚本发生。 SetTimer的尝试,而不是
所以不是
Loop
{
If run =
{
sleep,250
continue
}
Else
{
if (Team = "Red") ; If Red is selected, run this part
{
ACTION1HERE
}
if (Team = "Blue") ; If Blue is selected, run this part
{
ACTION2HERE
}
if (Team = "Green") ; If Green is selected, run this part
{
ACTION3HERE
}
}
}
return
F4::
If run =
run = 1
Else
run =
return
尝试
F4::
If run =
{
run = 1
Settimer, actionloop, 250
}
Else
{
run =
Settimer, actionloop, off
}
return
actionloop:
if (Team = "Red") ; If Red is selected, run this part
{
ACTION1HERE
}
if (Team = "Blue") ; If Blue is selected, run this part
{
ACTION2HERE
}
if (Team = "Green") ; If Green is selected, run this part
{
ACTION3HERE
}
return
我彻底明白了,太感谢你了! – user2308604 2013-04-27 17:00:38