problem with multiple #If

Get help with using AutoHotkey and its commands and hotkeys
b0bi
Posts: 6
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: 6
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=autohotkey] forum tag to share your code.
Click on (Accept this answer) on top-right part of the post if it has answered your question / solved your problem.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bad husband, Bing [Bot] and 16 guests