detuur / mpv-scripts

This is a collection of my own mpv scripts.
MIT License
54 stars 9 forks source link

Tips, tricks, and Q&A #13

Open AziRizvi opened 11 months ago

AziRizvi commented 11 months ago

Admin edit: This issue thread is not an issue/bug/question per se, but also not something I want to close and put out of sight of new users. A wiki is overkill for this project, so I figured a single pinned thread is a nice, low-barrier-of-entry, and visible approach for simple tricks, tips, and questions. Feel free to share ideas and converse about the project here.

--@detuur

original post:

Nifty way to use Boss-Key.lua with AutoHotKey

This is not an issue thread. I Just thought I'd share something.

I'm using your Boss-Key.lua script with an Autohotkey software combination.

Just in case if you didn't know, AutoHotkey is a free program aimed at providing easy keyboard shortcuts, hotkeys and fast macro-creation.

https://en.wikipedia.org/wiki/AutoHotkey

So the way I'm using your script in conjunction with AutoHotKey is like this:

Whenever the escape button is pressed on my keyboard First the AutoHotKey script that I've set up intercepts that input, modifies it and then sends it in whatever combination you wish/prefer.

So the way I've set it up is that when the escape button is pressed it sends in the Escape Button Command which pauses and minimizes MPV and after that it sends in another command which initiates a second script that removes the window from the windows taskbar effectively hiding whatever you were watching from prying eyes.

Source for the hide window script: https://www.computoredge.com/AutoHotkey/Downloads/HideWindow.ahk

My AutoHotkey Escape Button Script:

Esc::
sleep 1
Send {Esc}
sleep 3
Send #h
return
detuur commented 11 months ago

That's very neat. I'll keep the issue open but tag it with a discussion tag. I've added a little explainer to the top of your post.

As for some trivia, originally I made the boss-key script in AutoHotkey as well, but it wasn't very portable as you needed the AutoHotkey software and it would be tied to Windows. This is how I arrived at the solution of embedding a PowerShell script that calls the native win32 api. It's incredible how difficult it is to script for Windows without using third-party tools.

AziRizvi commented 11 months ago

Here's a video of just the Boss-key.lua script in action and the Boss-Key.lua the script in action with combination with AutoHotkey.

https://github.com/detuur/mpv-scripts/assets/129892077/ddd6b5f3-985b-4f57-8dd9-7b35a303a312

First I show how the Boss Key script behaves normally when the video gets paused and the player gets minimized, that's how the Boss-Key script behaves by default but when I add in the combination with AutoHotkey, it pauses and minimizes the player first and then sends in the command to initiate the second script that removes the player from the taskbar and hides it then I restore it using another command in the script which is Windows Key + U.

Anyone can change the keybinds to whatever they wish. But they'd have to modify my script to accommodate the Keybind change too.