Code: Select all
$vkB3::
If !TvkB3
SetTimer, TvkB3, -400
TvkB3++
Return
TvkB3:
If TvkB3 = 3
Send, {Media_Prev}
Else If TvkB3 = 2
Send, {Media_Next}
Else If TvkB3 = 1
Send, {Media_Play_Pause}
TvkB3 =
Return
Code: Select all
$vkB3::
If !TvkB3
SetTimer, TvkB3, -400
TvkB3++
Return
TvkB3:
If TvkB3 = 3
Send, {Media_Prev}
Else If TvkB3 = 2
Send, {Media_Next}
Else If TvkB3 = 1
Send, {Media_Play_Pause}
TvkB3 =
Return
Code: Select all
$Media_Play_Pause::
Hotkey, IfWinActive
Hotkey, Media_Play_Pause Up, On
HoldEnough := false
if !ClicksCount
SetTimer, NoHold, -450
TimeStamp := A_TickCount
SetTimer, Hold, -150 ; Hold at minimum 150 ms
KeyWait, Media_Play_Pause ; It is how we prevent re-launching of this subroutine while the button isn't released.
return
Media_Play_Pause Up:: ; Released before timeout.
SetTimer, Hold, Off
ClicksCount++
return
Hold: ; Was hold for at least 150 ms
Hotkey, IfWinActive
Hotkey, Media_Play_Pause Up, Off
SetTimer, NoHold, Off
HoldEnough := true
Switch ++ClicksCount
{
Case 2: Send, ^{Right} ; fast forward 10 seconds in Spotify
Case 3: Send, ^{Left} ; rewind 10 seconds in Spotify
Case "", 1: MsgBox, You've pressed once and hold Media_Play_Pause button.`nYou can bind some function for this free case `;-).
}
ClicksCount := 0
return
NoHold: ; Timed out 450 ms before release.
if GetKeyState("Media_Play_Pause", "P") ; If the button isn't released yet.
{ Sleep, % (171 + TimeStamp - A_TickCount) ; It is always positive, otherwise we won't be here.
if HoldEnough
return
}
Switch ClicksCount
{
Case 3: Send, {Media_Prev}
Case 2: Send, {Media_Next}
Case 1: Send, {Media_Play_Pause}
}
ClicksCount := 0
return
This code works amazingly! I was thrown off as to why the fast forward and rewind of 10 seconds didn't work, but I realized that Spotify doesn't even have that feature, it's simple skip or previous If the keybinds (double tap hold/triple tap hold) do exist though, I am sure I can use them for other features! Thank you so much for the script!amateur+ wrote: ↑26 Dec 2021, 00:51About sending Ctrl+Right and Ctrl+Left to Spotify. I need to know WinTitle of Spotify window. Can you tell me it? What is the name of an exe-file? What is the caption of its window?
Otherwise my code will fast forward and rewind only if Spotify window is active (has focus).
If the process name is Spotify.exe, you can try this:Spoiler
Yesterday I read about Spotify on Wiki and decided to install it. Nice service, I'll use it, thanks!Darkeh wrote: ↑26 Dec 2021, 20:29This code works amazingly! I was thrown off as to why the fast forward and rewind of 10 seconds didn't work, but I realized that Spotify doesn't even have that feature, it's simple skip or previous If the keybinds (double tap hold/triple tap hold) do exist though, I am sure I can use them for other features! Thank you so much for the script!
Code: Select all
...
Switch ClicksCount
{
Case 3: ChromiumSendKey("^s", "ahk_exe Spotify.exe") ; toggle Shuffle in Spotify
Case 2: ChromiumSendKey("^r", "ahk_exe Spotify.exe") ; toggle Repeat in Spotify.
...
}
ClicksCount := 0
return
ChromiumSendKey(pKey, pTitle) {
SetTitleMatchMode, 2
if (Hwnd := WinExist(pTitle))
{ if WinActive("ahk_id " . Hwnd)
Send, % pKey
else {
; Chromium ignores keys when it isn't focused.
; Focus the document window without bringing the app to the foreground.
ControlFocus, Chrome_RenderWidgetHostHWND1, % "ahk_id " . Hwnd
Sleep 20
ControlSend, , % pKey, % "ahk_id " . Hwnd
}
}
return Hwnd
}
Users browsing this forum: balawi28, Bing [Bot], Chunjee, moltenchees and 271 guests