Remote control "use" function

I’ve been thinking for a while that a tool (maybe a swep) that could “use” (e.g. the same as ‘e’ on the keyboard) at a distance would be very useful, there’s probably an easy way to do this in the console but i would prefer a swep, possibly with some form of scope or zoom. if this has been done already sorry and could you post a link, otherwise any one who want to have a go or help please post results/any helpful info.
Cheers

here is it [lua]if SERVER then
AddCSLuaFile(“shared.lua”)
end

if CLIENT then
SWEP.PrintName = “User”
SWEP.Slot = 2
SWEP.SlotPos = 5
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
end

SWEP.Author = “Slay3r36”
SWEP.Instructions = “left or right click to use something”
SWEP.Contact = “”
SWEP.Purpose = “”

SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.AnimPrefix = “”

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.NextStrike = 0

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “”

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “”

function SWEP:Deploy()
if SERVER then
self.Owner:DrawViewModel(false)
self.Owner:DrawWorldModel(false)
end
end

function SWEP:Initialize()
if SERVER then
self:SetUseType( SIMPLE_USE )
end
end
function SWEP:PrimaryAttack()
if SERVER then
local trace = self.Owner:GetEyeTrace()
if (!trace.Entity) then return false end
if (!trace.Entity:IsValid() ) then return false end
if (trace.Entity:IsWorld()) then return false end

            if trace.Entity.Use and trace.Entity.GetPlayer then
            trace.Entity:Use(trace.Entity:GetPlayer())
        else
            trace.Entity:Fire("use","1",0)
        end
        end

end
function SWEP:SecondaryAttack()
if SERVER then
local trace = self.Owner:GetEyeTrace()
if (!trace.Entity) then return false end
if (!trace.Entity:IsValid() ) then return false end
if (trace.Entity:IsWorld()) then return false end

            if trace.Entity.Use and trace.Entity.GetPlayer then
            trace.Entity:Use(trace.Entity:GetPlayer())
        else
            trace.Entity:Fire("use","1",0)
        end

end
end
[/lua]
Put it in lua/weapons/userswep/shared.lua

cheers