Hotkey long or short for Play next, play previous

Ask gaming related questions
NaCloridium
Posts: 3
Joined: 20 Sep 2020, 04:56

Hotkey long or short for Play next, play previous

20 Sep 2020, 05:21

Hey there, i am currently struggling trying to use a single key (In my case "F130") for two actions, like:

If F13 is pressed short (max. 50ms) it skips the track
If F13 is pressed long (more than 100ms) it plays the previous track
Can anyone help? I only could make it like so (It's kind of example code from the Corsair Forum and not my own code):

If F13 is pressed twice fast, it skips the track,
If F13 is pressed twice slow, it plays the previous track.

Can anyone help?

This is the code:
-------------------------------------------------------------

Code: Select all

global wasHeld:=false
F13::
	if !wasHeld
	{
		Clock:=A_TickCount
	}
	wasHeld:=true
return
F13 Up::
	if (A_TickCount >= Clock + 500)
	{
		;print("h")
		Send, {Media_Prev}
	}
	else {
		;print("o")
		Send, {Media_Next}
	}
	wasHeld:=false
return
------------------------------------------------------------- [Mod edit: [code][/code] tags added.]
NaCloridium
Posts: 3
Joined: 20 Sep 2020, 04:56

Re: Hotkey long or short for Play next, play previous

20 Sep 2020, 15:34

Doesn't anybody know an answer?
User avatar
Yakshongas
Posts: 591
Joined: 21 Jan 2020, 08:41
Facebook: Yakshongas

Re: Hotkey long or short for Play next, play previous

20 Sep 2020, 17:12

NaCloridium wrote:
20 Sep 2020, 05:21
If F13 is pressed short (max. 50ms) it skips the track
If F13 is pressed long (more than 100ms) it plays the previous track
Easy with KeyWait

Code: Select all

F13::
KeyWait, % A_ThisHotKey, T0.5
If (Errorlevel = 1)
{
    Send, {Media_Next}
}
Else if (ErrorLevel = 0)
{
    Send, {Media_Prev}
}
Return
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹
NaCloridium
Posts: 3
Joined: 20 Sep 2020, 04:56

Re: Hotkey long or short for Play next, play previous

21 Sep 2020, 03:23

Thanks, but: It simply keeps skipping until i press it again... not really what i want. Or am i wrong using only your code?

Return to “Gaming”

Who is online

Users browsing this forum: Bing [Bot] and 9 guests