Page 1 of 1

problem with multiple #If

Posted: 21 Oct 2017, 03:48
by b0bi
I'm trying to get this to work

Code: Select all

#IfWinActive ahk_class Notepad
{

  #If on_top=1   ;on_top is a personal variable
  {
    a::
    MsgBox, Triggered
    return
  }
  #If
}
#IfWinActive


The problem is:
It doesn't really check if active window is really Notepad... As soon as on_top=1 and I press "a", it triggers.... Any way to make it respct both condiction (logical and) ?

Re: problem with multiple #If

Posted: 21 Oct 2017, 03:54
by b0bi
solved !!!


Code: Select all

#If on_top=1 and WinActive("ahk_class OneNote")

    a::
    MsgBox, Triggered
    return



#If

Re: problem with multiple #If

Posted: 21 Oct 2017, 06:25
by SirRFI
Yes, You can't nest #If, because it replaces the last one used. Code flow doesn't affect it, unlike regular If.