How to make my macro work over programs open?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mateus Campello
Posts: 4
Joined: 15 Aug 2016, 10:28

How to make my macro work over programs open?

25 Sep 2017, 13:39

Hey there guys, for a while I've been using a macro for my iTunes functionalities so I don't have to alt tab to change musics and stuff while I'm playing or something else. The issue I have, though, is that it interacts weirdly with other programs open or is blocked by programs, example: When I'm playing Euro Truck Simulator, it works for volume, but not for music skip/previous/pause, when I try to do that, it activates the blinkers or hazards (which are binded to Q, E and P), League of Legends completely blocks any of it's functionalities and most recently, Discord is blocking it's functionalities aswell, which is the one I take issues with.

How could I make so my macro doesn't interact with the programs open and go directly to iTunes? Is that even possible? I did not make the macro, my friend did for me a while back, and I was trying to use ControlSend to try solve the problems, but I couldn't make it work and also noticed the volume already uses ControlSend (probably why it works in Euro Truck?) and volume doesn't work while Discord is open either. Here's the code:
Spoiler
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to make my macro work over programs open?

25 Sep 2017, 13:49

Try to use ControlSend on your first three hotkeys there that control the previous/next/play/pause. You mention ETS let the volume buttons work fine, which are using the ControlSend.

Now as to LoL or Discord blocking functionality, I don't know why that may be. You can try specifying in the WinTitle parameter "ahk_class iTunes" explicitly for ControlSend. I honestly don't know if the current code that omits the WinTitle works. If you read https://autohotkey.com/docs/misc/WinTit ... oundWindow it mentions that the "Windowing commands" (with an example of WinActivate) will use the LastFoundWindow in conjunction with the "IfWinExist" command. But I am suspecting that ControlSend may need the explicitly given WinTitle, or else it targets the active window. And in this case, it's just coincidence that the volume up and volume down hotkeys seem to work for ETS "passing along" those keys to iTunes. That's not definitive, but could be a problem.
Mateus Campello
Posts: 4
Joined: 15 Aug 2016, 10:28

Re: How to make my macro work over programs open?

25 Sep 2017, 15:37

Exaskryz wrote:Try to use ControlSend on your first three hotkeys there that control the previous/next/play/pause. You mention ETS let the volume buttons work fine, which are using the ControlSend.

Now as to LoL or Discord blocking functionality, I don't know why that may be. You can try specifying in the WinTitle parameter "ahk_class iTunes" explicitly for ControlSend. I honestly don't know if the current code that omits the WinTitle works. If you read https://autohotkey.com/docs/misc/WinTit ... oundWindow it mentions that the "Windowing commands" (with an example of WinActivate) will use the LastFoundWindow in conjunction with the "IfWinExist" command. But I am suspecting that ControlSend may need the explicitly given WinTitle, or else it targets the active window. And in this case, it's just coincidence that the volume up and volume down hotkeys seem to work for ETS "passing along" those keys to iTunes. That's not definitive, but could be a problem.
Hey there! I really appreciate the help, but I tried using "ControlSend, {Media_Play_Pause}, ahk_class iTunes" and "ControlSend, , {Media_Play_Pause}, ahk_class iTunes" for play/pause and neither worked, I'm sorry if it's a stupid mistake, but what am I doing wrong?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to make my macro work over programs open?

25 Sep 2017, 16:06

Try using ControlSend, ahk_parent, {Media_Play_Pause}, ahk_class iTunes. The volume up/down commands are using the ahk_parent as the control parameter, so you may need to do so for these commands too.

That of course is not a guarantee, and it may not fix it in LoL or Discord. I think it'd be most appropriate to test in ETS first to see if any changes happen there, even though your goal includes getting the script to work with Discord again.
Mateus Campello
Posts: 4
Joined: 15 Aug 2016, 10:28

Re: How to make my macro work over programs open?

26 Sep 2017, 08:43

Exaskryz wrote:Try using ControlSend, ahk_parent, {Media_Play_Pause}, ahk_class iTunes. The volume up/down commands are using the ahk_parent as the control parameter, so you may need to do so for these commands too.

That of course is not a guarantee, and it may not fix it in LoL or Discord. I think it'd be most appropriate to test in ETS first to see if any changes happen there, even though your goal includes getting the script to work with Discord again.
Weirdly, this one didn't work either. I don't have much hope it's gonna work on Discord again, but alright, what can we do.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to make my macro work over programs open?

26 Sep 2017, 11:48

Just a couple last-ditch ideas from me being unfamiliar with all of these softwares:

1) You can try running your script as an administrator.

2) You might try a different key combo for play/pause as supported by iTunes? If Ctrl+Up and Ctrl+Down change volume instead of using say a {Volume_Up} or {Volume_Down} key, maybe there are other Ctrl+__ combos you can use in iTunes.
Mateus Campello
Posts: 4
Joined: 15 Aug 2016, 10:28

Re: How to make my macro work over programs open?

26 Sep 2017, 13:05

Well, seems like all hope is lost, it didn't work. I tried "K" as activator and tried to remove parts of the code aswell, all while in desktop, but no luck. Thanks for the help anyways, buddy, I appreciate.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], hedehede81, OrangeCat and 322 guests