首页 > 解决方案 > IF 循环之一无法正常工作,我不知道为什么

问题描述

我在 SEO 上做了很多工作,所以我给自己做了一个快速检查网站的快捷方式,问题是由于某种原因,函数内的第二个 IF 语句无法正常工作(如果我输入“seo”,它会询问我的域想要检查并正常运行,但如果我输入“whois”,输入框不会弹出,它会直接跳转到 whois.domaintools.com 网站(没有 URL 扩展名)

这是我到目前为止所做的代码

collectAction(){
InputBox, userAction, ,Which action would you like to perform?, , 300, 120, ,, Arial,
if(userAction="seo")
    InputBox, seoUrl, ,Please enter the domain you want to check., , 300, 120, ,, Arial,
    Run, https://freetools.seobility.net/en/seocheck/check?url=https`%3A`%2F`%2Fwww.%seoUrl%`%2F&crawltype=1
    return
if(userAction="whois")
    InputBox, whoisUrl, ,Please enter the domain you want to check., , 300, 120, ,, Arial,
    Run, https://whois.domaintools.com/%whoisUrl%
    return          
}

提前致谢!ps 如果此信息对我使用热键 (F1) 调用此函数的过程有任何影响

标签: autohotkey

解决方案


将两个连续的 if 状态更改为 if - else 有效

collectAction(){

InputBox, userAction, ,Which action would you like to perform?, , 300, 130, ,, ,
if(userAction="seo") {
    InputBox, seoUrl, ,Please enter the domain you want to check., , 300, 120, ,, ,
    Run, https://freetools.seobility.net/en/seocheck/check?url=https`%3A`%2F`%2Fwww.%seoUrl%`%2F&crawltype=1
    return
}
else if(userAction="whois") {
    InputBox, whoisUrl, ,Please enter the domain you want to check., , 300, 120, ,, ,
    Run, https://whois.domaintools.com/%whoisUrl%
    return          
    }
}

函数调用示例:

F1::
collectAction()
return

推荐阅读