Two If conditions Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
spaceowl
Posts: 18
Joined: 16 May 2021, 06:46

Two If conditions

Post by spaceowl » 24 Jan 2022, 09:53

Hello,

I have a short code, which opens with alt and p in windows explorer the preview pane on the right side and maps the space bar to an control click on the preview pane play button, so that I can play sound files without opening in a player. When I close the pane again with alt p, the control click unmaps from the space bar, so that it can send blank space again.

This is the code:

Code: Select all

#IfWinActive ahk_class CabinetWClass
~!p::
mode:= 1
sleep, 1000
while !(GetKeyState("p", "P") and GetKeyState("alt", "P")) 
sleep, 50
mode:= 0
return

#If mode
Space::ControlClick,x1245 y565,A
#If
However, while the preview pane is open, I cannot of course use the space bar in another programs, like Notepad, Word, Outlook...

Is would like to use the space bar mapping only in windows explorer, I need the "if mode" only work in windows explorer, something like this:

Code: Select all

#If mode AND #IfWinActive ahk_class CabinetWClass
Space::ControlClick,x1245 y565,A
#If
Is there a way?

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: Two If conditions  Topic is solved

Post by mikeyww » 24 Jan 2022, 10:06

Code: Select all

#If mode && WinActive("ahk_class CabinetWClass")
Space::ControlClick,x1245 y565,A

#IfWinActive ahk_class CabinetWClass
~!p::
mode := 1
; .......
Return
#IfWinActive

Post Reply

Return to “Ask for Help (v1)”