How to show a song Spotify while minimizing it?
Well, that's why the Spotify application on Windows does not have built-in support for global hot keys and very simple hot keys, even if the application window is active. The disappointment of the "main role" of the song that is currently playing does not have a keyboard shortcut, even when the window is active.
So, I have an Autohotkey script that gives me global hot keys for controlling playback, volume and copying the name of the song (including em dash fixing), but I hit a brick wall trying to figure out how to draw the current song.
To make things even more complicated, I want the Autohotkey script to launch a song if it wasn’t removed. If he has already starred, just leave him alone.
I want all this to happen when the application is in the tray without opening the window.
EDIT: Semi-Separate Solution
So, I came up with a reasonable solution, it opens a context menu, even when the program is minimized and does everything, including uncontrolled songs. Unfortunately, the context menu means that it minimizes full-screen applications, such as games within a second. Depending on the game, which can be a pain, but this is the best I can do without fancy calls, etc.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ;|---------------| ;|--[ SOURCES ]--| ;|---------------| ;Base Spotify Script from: http://www.autohotkey.com/board/topic/36239-spotify-global-hotkeys/ ;Base Starring Script from: http://superuser.com/questions/324416/any-spotify-tweaks-with-keyboard-shortcut-to-star-tracks ;|------------------| ;|--[ SETTING UP ]--| ;|------------------| DetectHiddenWindows, On ;Detect Spotify even if it minimized
I changed some existing scripts that were hidden on the Internet. The sources of which can be found at the top of the source code, this can help if someone wants to try to get it to work completely without the context menu appearing.
How can you play a song in normal use of the application?
There seem to be only 2 routes to play a song on Spotify.
- Right-click on the album cover in the lower left corner and use the context menu option.
- Right-click on a song in the list of playlists and use the context menu option.
To make things uncomfortable, the star menu option is replaced by the Noar menu option in the same place if something is already taken. They also have the same hotkey when the menu is open (t key). Thus, you cannot just make a blind menu choice without any verification.
So what are the possible routes we can take?
Right-clicking on the album cover in the lower left is the only realistic route.
If we can read the text from the context menu and minimize it, we can say that something has already been marked by changing the text from “star” to “nestar”. After this test, we can decide whether to press the T key to actually play the song.
I also spent some time with Window Detective to see if I could just send the relatively simple PostMessage / SendMessage to play the song. But I have very little experience, and I don’t know how to tie them together to get the result I want.
I found out that the Star and Custom Context menu options are actually different:
Star -> WM_MENUSELECT (0x11F) | item identifier = 11 | flags = NONE | MF_HILITE Unstar -> WM_MENUSELECT (0x11F) | item identifier = 12 | flags = NONE | MF_HILITE
However, I do not know how to actually combine PostMessages / SendMessages to open the menu, and then select only item No. 11, and then press enter.
List of messages that Spotify receives when playing something
Just in case, this helps determine if the PostMessage / SendMessage route is possible.
->WM_RBUTTONDOWN (0x204) ->WM_RBUTTONUP (0x205) ->WM_MENUSELECT (0x11F) <-WM_MENUSELECT (0x11F) ->WM_KEYDOWN (0x100) ->WM_MENUSELECT (0x11F) <-WM_MENUSELECT (0x11F) ->WM_KEYUP (0x101)
Afterword
I searched for a while trying to find some good examples of PostMessages / SendMessages that are used to select such a context menu, but didn't find anything.
Thank you for your time.
Current Autohotkey Script
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; "CTRL + ALT + PAGEUP" for previous ^!PGUP:: { DetectHiddenWindows, On ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow DetectHiddenWindows, Off return } ; "CTRL + ALT + PAGEDOWN" for next ^!PGDN:: { DetectHiddenWindows, On ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow DetectHiddenWindows, Off return } ; "CTRL + ALT + HOME" for pause ^!Home:: { DetectHiddenWindows, On ControlSend, ahk_parent, {space}, ahk_class SpotifyMainWindow DetectHiddenWindows, Off return } ; "CTRL + ALT + END" for info ^!End:: { DetectHiddenWindows, On WinGetTitle, spotify_playing, ahk_class SpotifyMainWindow DetectHiddenWindows, Off StringTrimLeft, trimmed_playing, spotify_playing, 10 StringReplace, replaced_playing, trimmed_playing, –, -, All clipboard = %replaced_playing% return } ; "CTRL + ALT + UP" for volume up ^!Up:: { DetectHiddenWindows, On ControlSend, ahk_parent, ^{Up}, ahk_class SpotifyMainWindow DetectHiddenWindows, Off return } ; "CTRL + ALT + DOWN" for volume down ^!Down:: { DetectHiddenWindows, On ControlSend, ahk_parent, ^{Down}, ahk_class SpotifyMainWindow DetectHiddenWindows, Off return } ; "CTRL + ALT + INSERT" for starring the current song ^!Insert:: { DetectHiddenWindows, On DetectHiddenWindows, Off return }