New Windows iTunes Inactive Window Volume Keys

Post your working scripts, libraries and tools for AHK v1.1 and older
theneweetunes
Posts: 1
Joined: 16 Feb 2019, 12:53

New Windows iTunes Inactive Window Volume Keys

16 Feb 2019, 13:04

I know that title is a mouth full.

So I was using HKTunes as a dedicated global itunes macro application, however I was gifted a new phone and had to update itunes.

Of course, this broke HKTunes, so I had to figure out a solution.

The new itunes works with most media keys globally, but the media volume keys do the global volume, but I need my in game sounds still - so I had to figure out a solution for the volume keys.

iTunes has application specific hotkeys for this, i just had to figure out how to do that from in game without having to alt tab in a tense moment.

I decided to try and figure out if AHK could work for this, and after a couple of hours, I've gotten the following code to work as I needed.

Remember, this is just for the volume keys, as my keyboard allows me to set the macro keys to multimedia defaults - which work for an inactive itunes window now.

Code: Select all

;iTunes Volume Up ---- ---- (Ctrl+Up Arrow Key)
^Up::
DetectHiddenWindows, On ; Tells AHK to search for windows that are minimized/hidden

Target := "ahk_class iTunes"
IfWinNotExist %Target%
{
Return
}
ControlSend, ahk_parent, ^{Up}
return


;iTunes: Volume Down ---- ---- (Ctrl+Down Arrow Key)
^Down::
DetectHiddenWindows, On ; Tells AHK to search for windows that are minimized/hidden

Target := "ahk_class iTunes"
IfWinNotExist %Target%
{
Return
}
ControlSend, ahk_parent, ^{Down}
return
This is frankenstein'd from a few different scripts and tutorials and the "manual," but it seems to be the most effective solution, and as a complete newb, I wish someone would have posted something like this for me to use.

So here you go other noobs, good luck!

And if any pros have some optimizations, that's certainly welcome!
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: New Windows iTunes Inactive Window Volume Keys

16 Feb 2019, 21:05

for those looking for more actions instead of just volume up etc, someone made .vbs files that allow you to FastForward, etc
u just need to set a hotkey to run them. if interested I will upload.
Porkfist
Posts: 10
Joined: 22 Feb 2019, 16:01

Re: New Windows iTunes Inactive Window Volume Keys

22 Feb 2019, 16:21

I don't use iTunes, but this works for my media player, so I might be able to save you a few lines of code. Since I don't have iTunes installed I haven't tested this out; so you might have to tweak it.

Keep detect hidden windows on.

Code: Select all

#ifwinexist ahk_class iTunes ;if this window exists then enact these following hotkeys and override the defaults if they exist
^right:: controlsend ahk_parent, ^{right}, iTunes ;skip to next track
^left:: controlsend ahk_parent, ^{left}, iTunes ;skip to previous track
^space:: controlsend ahk_parent, {space}, iTunes ;play/pause
^up:: controlsend ahk_parent, ^{up}, iTunes ;volume up
^down:: controlsend ahk_parent, ^{down}, iTunes ;volume down
#ifwinexist ; if this window no longer exists then reset the hotkeys back to their default

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: kunkel321 and 43 guests