2

我有一个问题,AutoHotkey 告诉我{在“其他”前面有一个缺失,我认为我的代码非常好。(它一直有效,直到我将与窗口相关的 if 从 Pidgin 更改为 qutIM)

^!p::
   IfWinExist ahk_class QWidget, ,qutIM {  ;if there is a qutIM-window other than the buddy-list...
      IfWinNotActive ahk_class QWidget, , qutIM {  ;ans it is not active...
         WinActivate
      } else {  ;the closing bracket in front of the else here puts AHK off...
         WinMinimize
      } 
   } else {  ;do some stuff with the buddy-list
      ; [...]
   } 
return

我担心我忽略了一些愚蠢的事情,但我似乎无法让它发挥作用。

4

3 回答 3

2

如果我没记错的话,One True Brace 样式仅适用于纯 If 语句,不适用于 IfWinExist 之类的复合语句。

从 if-expressions 的文档中

One True Brace (OTB) 样式可以选择与作为表达式的 if 语句(但不是传统的 if 语句)一起使用。

IE。您必须使用 WinExist() 形式,而不是 IfWinExist。

于 2009-12-01T22:12:00.300 回答
-1

正如 PhiLho 所说,The One True Brace (OTB) 风格不能与复合 if 语句一起使用。

虽然 没有直接功能WinNotActive(),但您可以将!其用作相同效果的修饰符。

^!p::
   if WinExist("ahk_class QWidget", , "qutIM") {
      if !WinActive("ahk_class QWidget", , "qutIM") {
         WinActivate
      } else {
         WinMinimize
      } 
   } else {
      ; [...]
   } 
return
于 2017-08-28T19:28:26.257 回答
-2

由于我没有您正在对其进行测试的应用程序,因此我不确定您要让它做什么,但这可能是另一种方法:

^!p::
IfWinExist, ahk_class Notepad ; if there is a qutIM-window other than the buddy-list
    {
    WinActivate
    Exists=True
    }
else ;the closing bracket in front of the else here puts AHK off...
    {
    WinMinimize
    Exists=False
    }
If Exists=True 
    MsgBox, do some stuff with the buddy-list ; dummy code
Else
    {
    Msgbox, Exiting App ; dummy code
    ExitApp
    }
于 2009-12-09T23:36:58.150 回答