在脚本的其他部分中跳过第一个动作?

时间:2014-06-19 06:28:29

标签: if-statement autohotkey

当我转换下面的脚本时,会跳过重音行。谁能告诉我为什么?如何修复此问题,以使脚本正常工作?

MsgBox, 3, , Dimensions?, Wide (yes)?  Landscape (no)?
IfMsgBox, Yes
    Send ^+{PrintScreen}
    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    Send 1
    Return
IfMsgBox, No

    //SKIPPED
    //SKIPPED
    Send ^+{PrintScreen}
    //Skipped
    //Skipped

    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    Send 1
    Return
IfMsgBox, Cancel

    //SKIPPED
    //SKIPPED
    Send ^+{PrintScreen}
    //Skipped
    //Skipped
    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    Send 1
    Return

1 个答案:

答案 0 :(得分:1)

除非您使用Curly括号,否则只有IF语句后面的第一行才会被视为该语句的一部分。试试这个。 B.t.w.你是否意识到所有3个If都执行完全相同的代码?

MsgBox, 3, , Dimensions?, Wide (yes)?  Landscape (no)?
IfMsgBox, Yes
{
    Send ^+{PrintScreen}
    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    Send 1
    Return
}
IfMsgBox, No
{
    Send ^+{PrintScreen}
    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    Send 1
    Return
}
IfMsgBox, Cancel
{
    Send ^+{PrintScreen}
    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    Send 1
    Return
}