[WORKING] VLC Play/Pause on video-click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pureby
Posts: 8
Joined: 08 Jun 2019, 14:07

[WORKING] VLC Play/Pause on video-click

09 May 2021, 08:36

Hello comrades! If anyone wants their VLC Media Player to Play/Pause when clicking on the video, here is a simple script that I have just created:

Code: Select all

	#IfWinActive ahk_exe vlc.exe
;	.	[Play|Pause]
		~LButton::
			MouseGetPos, , , , VarCtrl
			if InStr(VarCtrl, "VLC video output")
			{
				Send, {Space}
			}
			VarCtrl := ""
			Return
	#IfWinActive
	return
This script simply emulates Space keypress (Play/Pause function in VLC) when left-clicking on the video (but not any other part of the VLC/Windows interface). Enjoy!


Spoiler
Last edited by pureby on 09 May 2021, 11:11, edited 3 times in total.
User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: if InStr() sometimes performs both {if} and {else} actions

09 May 2021, 09:37

In many video players, LButton and Space would have the same action in the main player window.

How do you know that Space is sent instead of LButton? If you exit the script and use native LButton, does it have the same actions?
pureby
Posts: 8
Joined: 08 Jun 2019, 14:07

Re: if InStr() sometimes performs both {if} and {else} actions

09 May 2021, 10:10

mikeyww wrote:
09 May 2021, 09:37
In many video players, LButton and Space would have the same action in the main player window.

How do you know that Space is sent instead of LButton? If you exit the script and use native LButton, does it have the same actions?
Thank you for the quick reply! I have actually tracked down the issue. It was not related to my script but was a VLC setting! Somehow I had the "Pause video playback on minimize" option turned on in my VLC Player settings. I think I ticked it by accident without noticing. Disabling this option made script work as expected.

[SOLVED]
pureby
Posts: 8
Joined: 08 Jun 2019, 14:07

Re: [SOLVED] if InStr() sometimes performs both {if} and {else} actions

09 May 2021, 10:27

There is another significant problem with the script, though. Sending {LButton} in the ELSE statament makes it so that you cannot drag anything. I have solved this by removing the ELSE statement alltogether and adding a tilde ~ before the LButton:: hotkey.

Now script in the OP works perfectly: video is Paused/Resumed when clicking on the video, all other VLC/Window/Taskbar/Mouse controls work unchanged.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333 and 376 guests