Mouse Click Append Line to Clipboard

This forum allows you to share scripts with other Zeus users. Please do not post bug reports, feature requests or questions to this forum, but rather use it exclusively for posting scripts or for the discussion of scripts that have been posted.
Post Reply
jussij
Site Admin
Posts: 2446
Joined: Fri Aug 13, 2004 5:10 pm

Mouse Click Append Line to Clipboard

Post by jussij » Tue Apr 15, 2014 4:21 am

This mouse click event macro will append the current line of text to the clipboard whenever the mouse is clicked on the line of text.

Refer to the description below on how to use the macro.

Code: Select all

--
--        Name: Mouse Click Append Line to Clipboard
--
--      Author: Jussi Jumppanen
--
--    Language: Lua Macro
--
-- Description: The click event macro will append the current line of
--              text to the clipboard.
--
--              To use the macro use the Options, Editor Optiosn menu
--              and in the Triggers panel add this to the Mouse Click
--              trigger:
--
--                   $zud\zScript\event_mouse_copy.lua
--
--              That line assumes the macro is saved to the zScript
--              folder as the event_mouse_copy.lua file.
--
function key_macro()
    if (is_document() == 1) then
        -- look for the line number
        for i = 1, argc(), 1 do
            -- Mouse Y argument will hold the line number
            local index, length, line = string.find(argv(i - 1), "MouseY=([%d:]+)")

            -- look for the line number argument
            if line ~= nil then
                -- append the line of text to the clipboard text
                local text = get_clipboard_text() .. get_line_text(line) .. "\n"

                -- put the combined text back into the clipboard
                set_clipboard_text(text)
                break;
            end
        end
    else
        -- macro only works for documents
        message("This macro only works for document files.");
        beep();
    end

    -- fire the default handler any any case
    set_return_code(0)
end

key_macro() -- run the macro

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 3 guests