Jump to content

ControlSend working like ControlClick: Spotify weirdness

Recommended Posts

I have the following line of code in my script:

ControlSend(WinGetTitle("[CLASS:SpotifyMainWindow]"), "", "", "^+{down}")

Which should send ctrl+shift+down (the built-in mute hotkey) to the Spotify window without it needing to be active. However, I have tested this and confirmed that this line is working exactly as if ControlSend() were replaced with Send(); that is, it works only if Spotify is the active window and does nothing otherwise. Everything I read suggests that ControlSend() should work properly, and although the documentation mentions "The control might first need to be given focus with the ControlFocus() command, specially when referencing an controlID created by the script itself", this shouldn't be relevant here since I am just trying to send the keys to the whole window and not a specific control; I tried adding a ControlFocus() to the main Spotify control called Chrome_RenderWidgetHostHWND but it didn't do anything.

Next I tried doing a ControlClick() to the coordinates of the mute button on the window but this also only worked with Spotify as the active window. Finally I used the Window Info tool to inspect the window and make sure that class:SpotifyMainWIndow was the correct name, and according to that tool the class of the Spotify window was CLASS:Chrome_WidgetWin_0. I retried both the ControlSend and the ControlClick versions of this using that class and, once again, it only worked with Spotify as the active window. It also interacted weirdly with WinActivate; although calling WinActivate() with the Chrome_WidgetWin_0 classname worked, no subsequent Send() or ControlSend() did anything, which is super strange because previously these functions worked when I manually activated the window before calling them, so why is it different for WinActivate()?

Furthermore, while I was testing, ControlSend randomly stopped working completely (not even when Spotify was active) and just as randomly started working again after I compiled the script and ran it as an .exe.

Is this an internal language bug? Some kind of security feature that Spotify uses to avoid being controlled by automation? How could we figure out which one of these cases it is?

I'm using the latest versions of Autoit, Windows 10, and Spotify. Any help would be much appreciated.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...