Skip to content

Instantly share code, notes, and snippets.

@ExtReMLapin
Created April 30, 2016 14:45
Show Gist options
  • Save ExtReMLapin/700fc33ee04f7df58020a564018bfbfd to your computer and use it in GitHub Desktop.
Save ExtReMLapin/700fc33ee04f7df58020a564018bfbfd to your computer and use it in GitHub Desktop.
hook.Add("Think", "MouseMove hook", function()
local x = gui.MouseX()
local y = gui.MouseY()
if x == 0 and y == 0 then return end -- cursor not enabled
if not gui.OldMouseX then -- first call
gui.OldMouseX = x;
gui.OldMouseY = y;
end
if ((gui.OldMouseY ~= y) or (gui.OldMouseX ~= x)) then
hook.Run("MouseMoved", gui.OldMouseX, gui.OldMouseY, x, y) -- oldX, oldY, X, Y
gui.OldMouseX = x;
gui.OldMouseY = y;
end
end)
hook.Add("MouseMoved", "test", function(oldX, oldY, X, Y)
print(SysTime(), oldX, oldY, X, Y)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment