views:

235

answers:

2

I have a problem with Autohotkey telling me there was a missing { in front of an else where I think my Code is perfectly fine (and worked until before 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.

A: 

If I am not mistaken, the One True Brace style is usable only with pure If statements, not with compounds like IfWinExist.
From manual: "The One True Brace (OTB) style may optionally be used with if-statements that are expressions (but not traditional if-statements)."
Ie. you have to use WinExist() form, not IfWinExist.

PhiLho
Thank you very much, this was the Solution for my problem (but I still wonder why it worked before then o.O)
Hofferic
A: 

Since I don't have the app you're testing it on I'm not really sure what you're trying to get it to do but this might be another way to go:

^!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
    }
it was about opening/hiding the chat-window of an multi-window IM-Client...As PhiLho pointet out i was just using the wrong notation for my if's, but thank you anyway ;)
Hofferic