po5 / evafast

mpv script for hybrid fastforward and seeking
41 stars 1 forks source link

Use Evafast with Mouse on Windows. #13

Open AziRizvi opened 10 months ago

AziRizvi commented 10 months ago

This is not an issue post, I'm using EvaFast on windows with my mouse and I thought I'd just share how, perhaps there should be a discussion/wiki section for posts like these.

If anyone wants to use this script with their mouse and is on windows and has a mouse with extra buttons, then you can use Evafast with your mouse using a small AutoHotKey script that I've written.

Download your mouse software and inside it, set the bindings of the extra buttons to obscure key combinations that windows doesn't use for anything. (E.g Ctrl/Shift/Alt/Win+Numpad or Ctrl/Shift/Win + Function Keys etc etc.)

After that, download & install the AutoHotkey software version 1.1. After it's installed, copy the code below paste it into a notepad file, replace ^Numpad8 with whatever keybind you used in your mouse software. In Autohotkey (^ is ctrl key), (! is alt key), (+ is shift key), (# is win key.).. put this modifier key along with the key that you binded in your mouse software, after that save the script as whatever name that you want to just make sure to put a .ahk at the end and then run the script by opening it in explorer. A green H icon will appear in your taskbar when its opened.

This AHK script will only work inside MPV because of the #IfWinActive section. (When you press the button on your mouse that is binded to the keybind that you just set inside this script, it will start simulating the right arrow key being physically pressed down by repeatedly sending the key every 40 milliseconds, once you press the button on your mouse it will keep fast forwarding and won't stop until you click the same button on your mouse and then it will "release" that key as if you just physically took your hand off of the right arrow key on your keyboard.)

If you're using multiple installations of MPV and want to use this with only a specific installation, replace the IfWinActive line below with this #IfWinActive, ahk_exe D:\MPV-2\mpv.exe

Make sure to change the path at the end.

This is the AHK script:

#IfWinActive ahk_exe mpv.exe

^Numpad8::

TheKeyIsPressed := !TheKeyIsPressed
    SetTimer, CheckWindow, % (TheKeyIsPressed) ? "0" : "1"
    SetTimer, KeyPress, 40
return

KeyPress:
    SetKeyDelay, -1
    if (TheKeyIsPressed)
        Send {Right Down}
    else
    {
        SetTimer, KeyPress, Off
        Send {Right UP}
    }
return

CheckWindow:                                                
    IfWinNotActive ahk_exe mpv.exe
    {
    TheKeyIsPressed := 0
        SetTimer, CheckWindow, Off
    }

return

#If