reddit / emacs
Emacs as a Keyboard Maestro or Autohotkey replacement
Mamonimoni · 2022-07-20 02:21
Would it be possible to use emacs as a keyboard macro and automation tool outside of emacs.
There is things like [keyboard maestro](https://www.autohotkey.com/) for mac or [autohotkey](https://www.autohotkey.com/) that let you create macros and assign them to keys in certain programs. Autohotkey uses an alien syntax and keyboard maestro is mostly mouse based. They are ok but I always wondered if using elisp and emacs would be a more powerful combination. Besides, it would ran on all platforms. Would emacs server be able to do something like this? Anyone ever tried to do something like this?
I have never tried EXWM but looking at performance I dont think it would work for me since this is for heavy post production tools.
Update: thanks for the Linux suggestions but I am looking for a solution that runs on Mac and Windows mostly since all post production tools widely used run on those.
dm_g · 2022-07-20 02:29
Personally, this is my take:
1. If I am in OSX, I use hammerspoon (with some help of karabiner). They are not macros, they are scripts you write in Lua.
2. if I am in Linux, I use the window manager (most are programmable). Again, they are not macros, they are scripts.
I have not seen emacs as the best tool for this (thought I might be wrong). Emacs does not have the functionality to control windows the way a window manager does.
MitchellMarquez42 · 2022-07-20 05:06
~~Passing through input will be an issue. On a typical desktop session, when you press a key or chord, it first goes to the OS (say, the Linux Kernel), then to the display server (say, Xorg), then to the window manager, and then to the current application. The OS and display server don't take very many keys (ex: power button, scroll-lock on Linux, ctrl+alt+del on windows) so you can pretty safely program keyboard actions at the window manager level. This is what EXWM has going for it.~~
...
I just remembered that https://www.youtube.com/watch?v=OMcpd9ixPOU exists. Do with it what you will.
BlondOlaf · 2022-07-20 05:27
If you want to use lisp to configure keyboard macros, I advise you to try kmonad, I just configured it yesterday and it's really great!
lycopodiopsida · 2022-07-20 05:41
I’ll speak for macOS: What hammerspoon, km and better touch tool have are trigger events. If emacs is not in focus it has no way to know what is happening in the system. Someone else have to call it on external events. Thus, it will be a pretty bad automation tool.
Mamonimoni · 2022-07-20 06:04
yeah, that's why I mentioned the emacs server. Maybe it could intercept all key presses that way.
Mamonimoni · 2022-07-20 06:05
This might be it!
Mamonimoni · 2022-07-20 06:05
This is linux only
Mamonimoni · 2022-07-20 06:07
Yeah, one of the goals was to use one tool and one language to rule all OSs. Emacs for everything right? I am ok with autohotkey but and keyboard maestro but I hate that I have to recreate everything per OS.
lycopodiopsida · 2022-07-20 07:18
It would require to implement a lot of OS-specific code (and maintain it). AFAIK in macOS these apps use the Accessibility API and access it with Objective-C. I doubt there are many Emacs developers who want to implement it. And it is only one OS, I have no idea how AHK works, but I highly doubt that it happens via beautiful and concise API.
What you could do - you could let such apps send requests to the emacsclient, could be even elisp code.
worthless-trash · 2022-07-20 08:20
>This is linux only
Not seeing the problem ;)
xircon · 2022-07-20 12:36
Espanso, cross platform, written in the 'cool kids' language (rust) works for me, though I cannot get it to run in wayland for some reason (it did! Think it has something to do with wxgtk2 being withdrawn).
deaddyfreddy · 2022-07-20 13:56
xbindkeys (yes, it supports Guile Scheme as an extension language)
Mamonimoni · 2022-07-20 16:45
>Espanso
very cool. Will check it out.
arthurno1 · 2022-07-20 22:11
You can certainly use Emacs as an automation tool, though not in the same way as a special purpose tool like Autohotkey. It would be more like automating with shell scripts, if that suits you.
I am sure Emacs as a scripting tool is quite powerful, similar to say python, bash or node when used for similar purpose, but I am not sure if it is more powerful then Autohotkey. They are not really covering same niche so to say.
When it comes to platform independence,, if you would like to automate platform specific tasks, there will always be a certain amount of things that are platform dependent. You mention EXWM, but that is a window manager for x11, you can't use that on Mac or Windows.
You don't say what you want to automate and in which way either, but you mention "heavy post production" tool. Many of those tools already have automation capabilities via built-in scripting languages, either Javascript, Python, TCL, VB or something else. You should maybe look at the builtin scripting capability they come with first?
Otherwise I suggest to take a look at either Tcl/Tk or Python. Emacs and Lisp are good, but as said, I would think of it more as of bash replacement or as an interactive tool, not so much as an automation tool as Autohotkey.
Mamonimoni · 2022-07-20 23:48
yeah, just wondering if it was possible. NLEs dont have much scripting support so most people use KM or autohotkey.
arthurno1 · 2022-07-21 00:14
What are "NLEs"?
Mamonimoni · 2022-07-21 15:01
non linear editor. Avid, Premiere etc
arthurno1 · 2022-07-21 16:09
All Adobe apps are scriptable, so are Avid tools too, Fusion, Nuke, Houdini, etc.
Even other professional fx, animation and editing tools are usually scriptable. I don't know what you are doing, but you should learn how to script premiere and combine it with a shell script. Using Autohotkey to click on buttons and open dialogs in the application is not the way to do it.
rswgnu · 2022-07-22 01:37
Check out the Emacs Application Framework and run your applications under Emacs where possible. Then you can use Hyperbole’s brace-delimited {key series} in any buffer to trigger application actions.
Mamonimoni · 2022-07-22 10:40
How is Avid scriptable? Can you point me to it?
Mamonimoni · 2022-07-22 10:40
Good idea!
arthurno1 · 2022-07-22 13:43
> How is Avid scriptable? Can you point me to it?
http://developer.avid.com/
Of course, when it comes to Avid, nothing is for free, you have to pay for "extension toolkits".
In my opinion, if you are looking for a very good NLE video editor, I suggest to look at Fusion. You have all the power of node (scenegraph) and NLE editing for both video and stills, and you can use python or lua for scripting.
Mamonimoni · 2022-07-22 14:59
Making a plugin is not what I would consider scriptable. Fusion is not an NLE.
arthurno1 · 2022-07-22 17:27
> Fusion is not an NLE.
Ah you are an expert. Sorry for bothering you.
Mamonimoni · 2022-07-23 05:42
I think you are confusing VFX tools with video editing.