Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

IfWinActive working strangely?


  • Please log in to reply
1 reply to this topic
DaveGL
  • Members
  • 4 posts
  • Last active: Sep 16 2014 05:02 PM
  • Joined: 28 Aug 2014

Using v1.1.x  I have many scripts that work normally.

Modified script from http://www.autohotke...IfWinActive.htm  :

IfWinActive, Untitled - Notepad
{
    ^F1::
WinMaximize  ; Maximizes the Notepad window found by IfWinActive above.
    Send, Some text.{Enter}
    return
}

Problems: Window doesn't maximize, text is sent regardless of what window is active. For testing, tried
 

IfWinActive, ddsfdfsdf
{
^F1::MsgBox Notepad Active!
}

Problem: MsgBox activates regardless of what window is active.

 

Question: How can I get AutoHotkey to recognize the active window?



vsub
  • Members
  • 1098 posts
  • Last active: Sep 28 2015 09:48 AM
  • Joined: 10 Nov 2011

That's strange,you are supposed to get an error if you try to run this scrip.

If you want the F1 key to work only when certain window is active,you should use one of those

 

F1:: ;without adding ~ the key normal function will always be blocked

KeyWait,F1

IfWinNotActive,your window

Return

Msgbox ;show a msgbox if the window is active

Return

 

Or

 

#IfWinActive, Untitled - Notepad

F1:: ;without adding ~ the key normal function will be blocked only when the window "Untitled - Notepad" is active.

Msgox

Return

 

http://www.autohotke...IfWinActive.htm