Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty12 committed Oct 9, 2022
1 parent ea45774 commit b61bc1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ To install this, just run `git clone https://github.com/qwerty12/mpv-taskbar-but
If you instead download the zipped version of this repo, just copy the mpv-taskbar-buttons folder as-is into your mpv scripts folder.
The files **must** be in a subfolder of your mpv scripts folder for this script to load. To get rid of this, just delete the folder.

Requests to add more buttons to this script will be ignored. If you have the code to perform a custom action already written but need help with adding a button to your own copy of the script to call it, make an issue. If you want to change what happens when one of the existing buttons are clicked, look at the `callbacks` table in hook.lua.
If you want to change what happens when one of the existing buttons are clicked, look at the `callbacks` table in hook.lua.

Requests to add more buttons to this script will be ignored. If you have code to perform a custom action already written but need help with adding a button to your own copy of this script to call it, make an issue. Windows allows up to seven buttons.

## Known issues

Expand Down
10 changes: 4 additions & 6 deletions hook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ffi.cdef [[
local WH_GETMESSAGE = 3
local WM_COMMAND = 0x0111
local MSGFLT_ADD = 1
local INFINITE = 0xFFFFFFFF
local INFINITE, WAIT_OBJECT_0 = 0xFFFFFFFF, 0x00000000
local GPTR = 0x0040
local PAGE_EXECUTE_READWRITE = 0x40
local SetEvent = C.GetProcAddress(C.GetModuleHandleA("kernel32.dll"), "SetEvent")
Expand All @@ -85,7 +85,6 @@ local lpCompiledCallback, lpGetMsgProc
local hHook = nil

local function generate_hook_callback()

-- Taken from https://github.com/nucular/tcclua
ffi.cdef [[
struct TCCState;
Expand Down Expand Up @@ -156,7 +155,7 @@ local function generate_hook_callback()
["SetEvent"] = SetEvent,
["CallNextHookEx"] = C.GetProcAddress(C.GetModuleHandleA("user32.dll"), "CallNextHookEx")
}) do
value = type(value) == "cdata" and tostring(value):match("^cdata<.+>: (.+)") or tostring(value)
value = type(value) == "cdata" and tostring(value):match("^cdata<.+>: (0x.+)") or tostring(value)
hook = hook:gsub("#" .. name .. "#", value)
end

Expand Down Expand Up @@ -211,10 +210,9 @@ _G.mp_event_loop = function()

while mp.keep_running do
local dwStatus = C.WaitForMultipleObjects(nEventCount, hEvents, false, dwTimeout - dwElapsed)
if dwStatus == 0 then --hMpvWakeupEvent signalled
if dwStatus == WAIT_OBJECT_0 then --hMpvWakeupEvent signalled
mp.dispatch_events(false)
end
if dwStatus == 1 then -- hCommandReceivedEvent signalled
elseif dwStatus == 1 then -- hCommandReceivedEvent signalled
local wmId = last_button_hit[0]
if callbacks[wmId] then
callbacks[wmId]()
Expand Down

0 comments on commit b61bc1b

Please sign in to comment.