我可以在 AutoHotKey 中将消息框的答案随机化吗?
Can I randomize answers to a message box in AutoHotKey?
我正在编写一个游戏,我需要在某个时候随机选择消息框的答案。我的意思是,如果点击“是”,则有 50% 的几率是正确答案,点击“否”也是如此。
像这样:
msgBox, 308, Spin!, Try your luck.
ifMsgBox Yes // replace Yes with function that randomly outputs yes or no here
{
msgBox, You're lucky!
}
else
{
msgBox, Sorry, try again.
}
我是 AHK 的初学者 — 基本上,我需要的是能够将 Yes 或 No 传递给 ifMsgBox 函数。这可能吗?
MsgBox, 308, Spin!, Try your luck.
ifMsgBox % myRandomFunction(answer)
MsgBox Lucky
else
MsgBox Not Lucky
myRandomFunction(answer)
{
Random answer, 0, 1
return answer == 1 ? "Yes" : "No"
}
您实际上并不需要 ifMsgBox,因为您忽略了用户的回答。
MsgBox 308, Spin!, Try your luck
Random random_num, 0, 1
MsgBox % random_num == 1 ? "You're lucky!" : "Sorry you lost"
我正在编写一个游戏,我需要在某个时候随机选择消息框的答案。我的意思是,如果点击“是”,则有 50% 的几率是正确答案,点击“否”也是如此。
像这样:
msgBox, 308, Spin!, Try your luck.
ifMsgBox Yes // replace Yes with function that randomly outputs yes or no here
{
msgBox, You're lucky!
}
else
{
msgBox, Sorry, try again.
}
我是 AHK 的初学者 — 基本上,我需要的是能够将 Yes 或 No 传递给 ifMsgBox 函数。这可能吗?
MsgBox, 308, Spin!, Try your luck.
ifMsgBox % myRandomFunction(answer)
MsgBox Lucky
else
MsgBox Not Lucky
myRandomFunction(answer)
{
Random answer, 0, 1
return answer == 1 ? "Yes" : "No"
}
您实际上并不需要 ifMsgBox,因为您忽略了用户的回答。
MsgBox 308, Spin!, Try your luck
Random random_num, 0, 1
MsgBox % random_num == 1 ? "You're lucky!" : "Sorry you lost"