0

下面是我使用的代码片段。如果您在浏览器中执行某些操作,它应该检测到您当前在浏览器中并将 URL 复制到剪贴板。如果您不在浏览器中,那么由于没有 URL,因此没有问题。

无论我在哪个浏览器中,第一个 MessageBox 总是输出值 0。但是,函数内部的 MessageBox 永远不会被激活,即“未检测到浏览器”消息永远不会显示。因此该值不能为零,但是当我在记事本中时,if 函数仍会被处理。

if (Retrieve_Browser_Type <> 0) 
    {
        Send, {F6}
        Send, ^{ins}
        URL = %clipboard%
        MsgBox, % Retrieve_Browser_type
        MsgBox, URL copied: %URL%
    }

Retrieve_Browser_Type() {
    IfWinActive, ahk_class MozillaWindowClass return 1
    IfWinActive, ahk_class Maxthon3Cls_MainFrm return 2
    IfWinActive, ahk_class IEFrame return 3
    IfWinActive, ahk_class Chrome_WidgetWin_1 return 4
    MsgBox, No browser detected
    return 0
}
4

1 回答 1

0

这是编译器没有检测到的语法错误。代替:

IfWinActive, ahk_class MozillaWindowClass return 1  

你应该写:

IfWinActive, ahk_class MozillaWindowClass 
return 1
于 2013-08-06T08:38:20.947 回答