Macro recording

132 views
Skip to first unread message

chris.d...@gmail.com

unread,
Feb 14, 2021, 6:53:57 AM2/14/21
to scite-interest
Hello,

Sorry if this has been asked before, but is there any chance that SciTE will support macro recording in the future?

If not, what are the alternatives?

Thx

John Yeung

unread,
Feb 14, 2021, 7:11:06 AM2/14/21
to scite-interest
> Sorry if this has been asked before, but is there any chance that SciTE will support macro recording in the future?
>
> If not, what are the alternatives?

I doubt that this feature will be developed, especially by the creator
of the software. I suppose there might be a chance that a
community-developed contribution would be accepted.

The main alternatives are (1) Lua and (2) system macro software, such
as AutoHotkey on Windows. I am sure Linux and Mac have something
similar.

John Y.

chris.d...@gmail.com

unread,
Feb 14, 2021, 7:17:29 AM2/14/21
to scite-interest
Thx for your reply.

I was looking into a lua script, but from what I can tell it is not possible to capture keystrokes with Plain lua...

Am I correct?

Op zondag 14 februari 2021 om 13:11:06 UTC+1 schreef John Yeung:

Mitchell

unread,
Feb 14, 2021, 9:46:09 AM2/14/21
to scite-i...@googlegroups.com
Hi,

On Sun, 14 Feb 2021 04:17:28 -0800 (PST)
"chris.d...@gmail.com" <chris.d...@gmail.com> wrote:

> Thx for your reply.
>
> I was looking into a lua script, but from what I can tell it is not
> possible to capture keystrokes with Plain lua...
>
> Am I correct?

There's an OnKey event you can try. I contributed it many years ago for more key customization. I don't remember if it can be used to capture insertion keystrokes like plain letters though.

Cheers,
Mitchell

Neil Hodgson

unread,
Feb 14, 2021, 4:50:42 PM2/14/21
to scite-i...@googlegroups.com
chris.de.boeck:

Sorry if this has been asked before, but is there any chance that SciTE will support macro recording in the future?

If not, what are the alternatives?

Filerx supported macro recording but I don’t think it is maintained.

   Neil

John Yeung

unread,
Feb 14, 2021, 10:40:24 PM2/14/21
to scite-interest
> Op zondag 14 februari 2021 om 13:11:06 UTC+1 schreef John Yeung:
>>
>> The main alternatives are (1) Lua and (2) system macro software, such
>> as AutoHotkey on Windows. I am sure Linux and Mac have something
>> similar.

On Sun, Feb 14, 2021 at 7:17 AM chris.d...@gmail.com
<chris.d...@gmail.com> wrote:
>
> I was looking into a lua script, but from what I can tell it is not possible to capture keystrokes with Plain lua...
>
> Am I correct?

I don't know, but I actually meant that you could write a Lua script
*instead of* recording keystrokes. Writing a script is probably not as
easy to do as recording a macro, but is also probably much more
powerful and flexible.

My other suggestion, of AutoHotkey, actually gives you close to the
best of both approaches.

John Y.

michel....@gmail.com

unread,
Feb 15, 2021, 3:41:11 AM2/15/21
to scite-interest

Hello

I tried monitoring key strokes to create readonly parts in a document, with an old version 3.

OnKey can be used but it may be difficult with modifiers

I stuck on the mouse and insertion point. Specially when using the middle button to click and paste over selection.

(I had to memorize the document and compare to check the readonly parts)

Best regards

chris.d...@gmail.com

unread,
Feb 15, 2021, 8:23:12 AM2/15/21
to scite-interest
Hi,

The OnKey event seems to capture everything I want, but now the question is, how do I send keystrokes to the editor?

Thx

Op maandag 15 februari 2021 om 09:41:11 UTC+1 schreef michel....@gmail.com:

buttim

unread,
Feb 15, 2021, 8:44:26 AM2/15/21
to scite-interest
Many years ago I wrote a macro manager for Scite's Windows version. It seems to still be working. It's a single C# file, first line tells you how to compile it.

It uses Scite's built-in interface for external macro managers, so you will need to launch it (no window, just an icon in the icon tray). Then you will be able to use the Tools menu (List macros and the next 3 entries).

You can give it a look, if you or anyone else is interested I'll be happy to document it.

macros4scite.zip

chris.d...@gmail.com

unread,
Feb 15, 2021, 11:28:50 AM2/15/21
to scite-interest
HI,

Thx for sharing! Documentation would be nice ;)

I compiled your program, but when I tried to execute it, nothing happened. 

In the windows event log I see the following:

System.DllNotFoundException
   at App.SetManagedHook(WH, IntPtr, UInt32)
   at App..ctor()
   at App.Main()


Op maandag 15 februari 2021 om 14:44:26 UTC+1 schreef buttim:

BugFix@AutoIt

unread,
Feb 16, 2021, 6:27:31 AM2/16/21
to scite-interest
Hi,
im using macros in this kind (it's SciTE4AutoIt, working with event class looks a little different). Here I'm using "Ctrl+Numpad1..6" to activate the macros:

Macro = EventClass:new(Common)

-------------------------------------------------------------------------
TimeOS = function() local datetable = os.date("*t", os.time())
return string.format('%02d:%02d:%02d', datetable.hour, datetable.min, datetable.sec)
end
-------------------------------------------------------------------------

-------------------------------------------------------------------------
GetProp = function(_prop)
return props[_prop]
end
-------------------------------------------------------------------------

-------------------------------------------------------------------------
LoremIpsum = function()
return
[[Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores
et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore
et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.]]
end
-------------------------------------------------------------------------

-------------------------------------------------------------------------
local scitemacro = function(_value)
local tMacro = {
[97]  = GetProp('FilePath'), -- NUMPAD-1  full path of the current file
[98]  = GetProp('FileDir'),  -- NUMPAD-2  directory of the current file without a trailing slash
[99]  = GetProp('FileName'), -- NUMPAD-3  base name of the current file
[100] = GetProp('FileExt'),  -- NUMPAD-4  extension of the current file
[101] = TimeOS(),            -- NUMPAD-5  current time
[102] = LoremIpsum()         -- NUMPAD-6  predefined text block
}
return tMacro[_value]
end
-------------------------------------------------------------------------

function Macro:OnKey(_keycode, _shift, _ctrl, _alt)
-- print('_keycode: '..tostring(_keycode)..', _shift: '..tostring(_shift)..', _ctrl: '..tostring(_ctrl)..', _alt: '..tostring(_alt))  -- DebugToConsole
-- our macro keys: "ctrl+NUMPAD-1 to NUMPAD-6"
local textMacro = scitemacro(_keycode)
if textMacro ~= nil and _ctrl and not _shift and not _alt then
editor:InsertText(editor.CurrentPos, textMacro)
return true -- avoids default processing
end
end

To send other editor commands, you can use scite.SendEditor(SCI_...).

buttim

unread,
Feb 16, 2021, 7:39:11 AM2/16/21
to scite-interest
Oh, I forgot half of it. You also need a small DLL compiled from the attached code.
To compile it use the following command

!cl /nologo /LDd /EHsc /W4  HookToManaged.c  HookToManaged.def user32.lib /link /section:rws,rws

Sorry about that

HookToManaged.zip

buttim

unread,
Feb 16, 2021, 7:40:43 AM2/16/21
to scite-interest
ignore the exclamation mark at the beginning of the line though (oh my!)
Reply all
Reply to author
Forward
0 new messages