I want AHK to do something, ONLY if a particular variable has a particular value.
Code:
<^<!/::
MsgBox,4,Timer,Do you want to set a timer?
IfMsgBox Yes
{
InputBox,Time1 , Timer, What hour? (Please show in 24:00 format)
InputBox,Time2,Timer, What minute?
IfTime1 := A_Hour, Time2 := A_Min
MsgBox,64,Timer,Timer done.
}
else{}
return
If you don't understand what I am trying to do, I'm trying to set a timer.
What I want:
When I press Ctrl+Alt+/, I want a msgbox to open, asking to set a timer or not.
If I click on Yes, I want two InputBox
es to open one by one, in which I will write the time.
Next, when I am done setting the time, the InputBox
will close. Now, The time in the InputBox
es will write to two variables named time
and time2
. Then, if time
is same as A_Hour
and time2
is same as A_Min
, a MsgBox
will show up with an info 🛈
icon.
What happens:
After setting the time, the MsgBox
with an info icon immediately shows up.
Can anyone correct the code above and send an answer? Thanks.
Edit:- This question gives you and me a lot of cringe. How did I not know about the
and
operator? Who knows! How did I not know about the=
comparison operator? Who knows! How did I not know about awhile true
loop basically acting as aforever
loop? Same thing, Who knows! At least now I do… Really sorry for that.
<^<!/::
MsgBox,4,Timer,Do you want to set a timer?
IfMsgBox Yes
{
InputBox, Time1, hour, What hour? (Please show in 24:00 format)
if ErrorLevel ; CANCEL was pressed
return
if (Time1 > 23)
{
MsgBox, wrong hour specification
return
}
InputBox,Time2, minute, What minute?
if ErrorLevel
return
if (Time2 > 59)
{
MsgBox, wrong minute specification
return
}
SetTimer, Timer, 1000
}
return
Timer:
if (A_Hour = Time1 && A_Min = Time2)
{
SetTimer, Timer, off
MsgBox,64,Timer,Timer done.
}
return