how do I prevent #ifwinexist from disabling other hotkeys Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mipha
Posts: 77
Joined: 27 Jul 2018, 17:08

how do I prevent #ifwinexist from disabling other hotkeys

17 Feb 2020, 10:29

Code: Select all

Hotkey, % "w", testkeys
return

testkeys:
msgbox a
return

#ifwinactive, test
return
With this script. Pressing W does not activate the testkeys part.
Is there away to change this up so that the hotkey works without removing the hotkey, % "w", testkeys part and the #ifwinactive part?
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: how do I prevent #ifwinexist from disabling other hotkeys  Topic is solved

17 Feb 2020, 10:35

use hotkey if,
To turn off context sensitivity (that is, to make subsequently-created hotkeys work in all windows), specify any If sub-command but omit the parameters. For example: Hotkey, If or Hotkey, IfWinActive.
If "Hotkey If" is never used by a script, the bottommost use of any #If or #IfWin directive (if any) will be in effect for the Hotkey command.
:arrow: src.

Cheers.
Mipha
Posts: 77
Joined: 27 Jul 2018, 17:08

Re: how do I prevent #ifwinexist from disabling other hotkeys

17 Feb 2020, 10:40

Helgef wrote:
17 Feb 2020, 10:35
use hotkey if,
:arrow: src.

Cheers.

Code: Select all


Hotkey, % "w", testkeys
return

testkeys:
msgbox a
return

hotkey, ifwinactive, test
return
This works perfectly. Thank you!
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: how do I prevent #ifwinexist from disabling other hotkeys

17 Feb 2020, 10:45

It should be,

Code: Select all

hotkey if
Hotkey, % "w", testkeys
return

testkeys:
msgbox a
return

#ifwinactive, test
; my hotkeys for window "test"
The line you replaced #ifwinactive, test with will never be executed and has no effect on the script.

Cheers.
Mipha
Posts: 77
Joined: 27 Jul 2018, 17:08

Re: how do I prevent #ifwinexist from disabling other hotkeys

17 Feb 2020, 10:53

Helgef wrote:
17 Feb 2020, 10:45
It should be,

Code: Select all

hotkey if
Hotkey, % "w", testkeys
return

testkeys:
msgbox a
return

#ifwinactive, test
; my hotkeys for window "test"
The line you replaced #ifwinactive, test with will never be executed and has no effect on the script.

Cheers.
After a bit more testing, that's what I noticed too. In the end I opted for

Code: Select all

Hotkey, % "w", testkeys
return

testkeys:
msgbox a
return

#ifwinactive, test
return
#ifwinactive ;<this has been added
which worked. But your solution seems good too.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: how do I prevent #ifwinexist from disabling other hotkeys

17 Feb 2020, 10:55

Yes that is ok too, but you always have to remember to keep the #if at the bottom if you add code to your script.

Cheers.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 338 guests