Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Grooveshark hotkeys windows


  • Please log in to reply
2 replies to this topic
Dreet
  • Members
  • 4 posts
  • Last active: Dec 02 2013 11:07 AM
  • Joined: 28 Nov 2013

Hi there,

I wrote this script which will send commands such as:

  • Play/Pause
  • Next and Previous song
  • Volume up, Volume Down
  • Mute sound
  • Set sound to the lowest level

to the Grooveshark tab in google's chrome browser. (If the tab is one of many in the background, the script will tab through them in order to find it)

 

It should be easy adjustable for firefox users etc.

 

It works for me, but I wanted to post it here so you can make suggestions. Maybe we can find better solutions.

 

The code is commented and I'm  ready for suggestions and questions:)

 

Latest Update 28.11.2013:

  • refactored code
  • added new functionalities
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; Author: GDur
; Description

SetTitleMatchMode, 2

chromeTitle		:= "ahk_class Chrome_WidgetWin_1"
grooveTitle		:= "Grooveshark - Listen to " chromeTitle
chromeClassnn	:= "Chrome_RenderWidgetHostHWND1"

isMuted			:= false

; special mouuse button + F1
XButton2 & F1::sendGrooveshark("mute_unmute")

XButton2 & F2::sendGrooveshark("voldown")
XButton2 & F3::sendGrooveshark("volup")

XButton2 & F4::sendGrooveshark("playpause")

XButton2 & F5::sendGrooveshark("previousSong")
XButton2 & F6::sendGrooveshark("nextSong")

XButton2 & F7::sendGrooveshark("minimum_volume")

sendGrooveshark(command) {
	global grooveTitle, chromeTitle, chromeClassnn
		
	; this function will send the command to grooveshark if the window exsit 
	; won't activate it

	Loop, 30 {
		if WinExist(grooveTitle) {
			; if it found the tab it will send the command and break out of the loop
			sendCommand(command)
			break
		}
		; if it didnt find the tab it will ctrl+tab in order to go to the next tab and check that too
		ControlSend, %chromeClassnn%, {Ctrl down}{Tab}{Ctrl up}, %chromeTitle%
	}
}

sendCommand(command) {
	global isMuted
	
	if(isMuted) {
		isMuted := false
		Loop, 11
			sendCommand("volup")
	} else {
		if (command = "playpause") {
			controlSend("{Space}")
		} else if(command = "volup") {
			controlSend("{Ctrl down}{Up}{Ctrl up}")
		} else if(command = "voldown") {
			controlSend("{Ctrl down}{Down}{Ctrl up}")
		} else if(command = "mute_unmute") {
			Loop, 25
				sendCommand("voldown")
			isMuted := true
		} else if(command = "previousSong") {
			controlSend("{Ctrl down}{Left}{Ctrl up}")
		} else if(command = "nextSong") {
			controlSend("{Ctrl down}{Right}{Ctrl up}")
		} else if(command = "minimum_volume") {
			Loop, 25
				sendCommand("voldown")
			sendCommand("volup")
		}
	}
}

controlSend(hotekys) {	
	global grooveTitle, chromeClassnn
	ControlSend, %chromeClassnn% , %hotekys%, %groovTitle%
}

; F5::Reload


rrhuffy
  • Members
  • 17 posts
  • Last active: Dec 11 2013 10:21 PM
  • Joined: 16 Apr 2012

Try this:

https://chrome.googl...ebkdphfikhkkopn

Or this:

https://chrome.googl...hndfbjdmopfdcab

 

Here is example for pausing:

SetTitleMatchMode 2 ; 2: A window's title can contain WinTitle anywhere inside it to be a match. 

~Media_Play_Pause::
ControlSend,Chrome_RenderWidgetHostHWND1,{ctrl down}{shift down}{Down}{shift up}{ctrl up},Google Chrome
return

Originaly I've had problems with not stable handler to Chrome (sometimes I must change RenderWidgetHostHWND1 or *2 or *3), but since about year handler number 1 is working for me without any problems, I have no idea why ;)



zloidooraque
  • Members
  • 7 posts
  • Last active: Jan 01 2016 12:54 PM
  • Joined: 20 Aug 2015

for some reason it just able send keypresses when chrome window is active.

don't you know anything on this?