problem with multiple #If

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
b0bi
Posts: 7
Joined: 07 Apr 2016, 13:11

problem with multiple #If

21 Oct 2017, 03:48

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) ?
b0bi
Posts: 7
Joined: 07 Apr 2016, 13:11

Re: problem with multiple #If

21 Oct 2017, 03:54

solved !!!


Code: Select all

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

    a::
    MsgBox, Triggered
    return



#If
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: problem with multiple #If

21 Oct 2017, 06:25

Yes, You can't nest #If, because it replaces the last one used. Code flow doesn't affect it, unlike regular If.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arcylix, drani, Google [Bot], Rohwedder and 226 guests