Context sensitive (#IfWinActive) doesn't work

Get help with using AutoHotkey and its commands and hotkeys
Guill
Posts: 138
Joined: 09 Jun 2016, 22:00

Context sensitive (#IfWinActive) doesn't work

26 Jun 2017, 21:17

Does anybody know why sometimes general scripts work, but do not do scripts inside #IfWinActive? The program does not generate messages of error, either.
User avatar
boiler
Posts: 12991
Joined: 21 Dec 2014, 02:44

Re: Context sensitive (#IfWinActive) doesn't work

26 Jun 2017, 21:34

Can you give an example? #IfWinActive only affects hotkeys that are defined following that directive. Those hotkeys will only work if the result of your #IfWinActive is true.
Guill
Posts: 138
Joined: 09 Jun 2016, 22:00

Re: Context sensitive (#IfWinActive) doesn't work

26 Jun 2017, 21:45

My usual script is very large, but, here you have an example :



F2::
Run notepad ; IT WORKS
Return


#IfWinActive ahk_class CabinetWClass

!3:: ; IT DOESN'T WORK
Run calc
Return

#IfWinActive



::::::::::::::::::::::

I must make it clear that it does not always happen. I suspect that some function of windows, or of another program that works in the background in some situation, can disable this. I can not explain what it can be. I just rebooted the computer, and everything worked again, but I would like to avoid this action.


Thanks in advance
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Context sensitive (#IfWinActive) doesn't work

26 Jun 2017, 21:51

One possibility:

Code: Select all

#IfWinActive ahk_class CabinetWClass
!3::
#IfWinActive ahk_class ExploreWClass
!3::
Run calc
Return
#IfWinActive
What Windows OS are you using?

You could try this to check the class of the active window:

Code: Select all

q:: ;get class of active window
WinGetClass, vWinClass, A
MsgBox, % vWinClass
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Guill
Posts: 138
Joined: 09 Jun 2016, 22:00

Re: Context sensitive (#IfWinActive) doesn't work

26 Jun 2017, 22:04

Thanks for your time,

My Windows is 8.1

Return to “Ask For Help”

Who is online

Users browsing this forum: HiSoKa, Kainie, mikeyww, nabbott22, Terka, wetware05 and 49 guests