复合行if语句在同一行花括号上的AutoHotkey阻塞 [英] AutoHotkey choking on same-line curly brace for compound if statements

查看:173
本文介绍了复合行if语句在同一行花括号上的AutoHotkey阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,即AutoHotkey告诉我在'else'前面缺少一个{,我认为我的代码很好. (直到我将与窗口相关的if从Pidgin更改为qutIM为止,它一直起作用)

I have a problem where AutoHotkey tells me there is a missing { in front of an 'else' where I think my Code is perfectly fine. (It worked up until I changed the window-related if's from Pidgin to 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

我担心自己忽略了一些愚蠢的事情,但似乎无法正常工作.

I fear I'm overlooking something stupid, but I cannot seem to get this working.

推荐答案

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

If I am not mistaken, the One True Brace style is usable only with pure If statements, not with compounds like IfWinExist.

摘自if表达式文档:

One True Brace(OTB)样式可以有选择地与 作为表达式的if语句(但不是传统的 if语句).

The One True Brace (OTB) style may optionally be used with if-statements that are expressions (but not traditional if-statements).

即.您必须使用WinExist()表单,而不是IfWinExist.

Ie. you have to use WinExist() form, not IfWinExist.

这篇关于复合行if语句在同一行花括号上的AutoHotkey阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆