Closed bamenny closed 5 years ago
Ah yes. That's because a #if will always overrule any previous #if thingies.
So, I have some code like this:
#if WinActive("ahk_class #32770") and WinActive("ahk_exe chrome.exe") ;An Explorer window as launched by Chrome
`::Send !{up} ;DOWN one folder level in explorer
#if
and I also have some code like this:
#if (getKeyState("F23", "P"))
numpad3::
if WinActive("ahk_exe Adobe Premiere Pro.exe")
SendKey(A_thishotkey, ,"orange")
if WinActive("ahk_exe chrome.exe")
sendinput, ^+{tab} ;go to previous tab in chrome
return
For you, it would be something like....
#if (getKeyState("F23", "P")) and if WinActive("ahk_exe POWERPNT.EXE")
m::msgbox, do whatever here
wait, maybe it's
#if (getKeyState("F23", "P")) and WinActive("ahk_exe POWERPNT.EXE")
m::msgbox, do whatever here
IDK. try stuff! the point is, you can use an AND. or an OR. or multiple ANDs!
Are you using pretty close to the default code, with a ~F24::
pr similar trigger?
In which case, don't use the # symbol before your ifwinactive as you are starting a new [subroutine] (not sure what it's called in AHK. You can see an example of my code which works as a global play/pause key.
~F23::
FileRead, key, C:\Users\[your username]\Documents\AHK Scripts\2nd-keyboard-master\LUAMACROS\keypressed.txt
If (key = "smample_keyname")
Send {Volume_Down}
else if(key = "numMult")
{
WinGet, WorkingWin ,, A ;Get current window ID
SetTitleMatchMode 2 ; 2: A window's title can contain WinTitle anywhere inside it to be a match.
IfWinActive, Radio 1,
[snip]
Wegerich, that code only works for the luamacros method. I believe bamenny is using the interception method.
Yes!!! Thanks! This one actually works great.
m:: if WinActive("ahk_exe POWERPNT.EXE") { send !l send p send m } return
Hi, Sorry if this is not the best place to ask this...
The moment I add the #IfWinActive command to the AHK script, AHK will accept Hotkey from BOTH keyboards.
#IfWinActive ahk_exe POWERPNT.EXE
m::
send !l
send p
send m
send {Enter}
return
Tried various combinations to solve this.... any ideas?