GithubHelp home page GithubHelp logo

Text Expansion about robotjs HOT 35 CLOSED

octalmage avatar octalmage commented on September 26, 2024 4
Text Expansion

from robotjs.

Comments (35)

WilixLead avatar WilixLead commented on September 26, 2024 12

Hello guys. I just implement libuiohook for node.js.
Now we can hook all keyboard and mouse events globally.
This module also support electron and nw.js
https://www.npmjs.com/package/iohook

PS. It is cross platform module already tested in Mac and Ubuntu. Should good work in windows and other systems, what supported from libuiohook

from robotjs.

octalmage avatar octalmage commented on September 26, 2024 1

I generally use nw.js for hotkeys but as you mentioned its lacking. I'm hoping they improve that because I don't think I want to include hotkey support in RobotJS. If I do work on it, it will be a separate module. I think I'm going to do the same for window management.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024 1

I ran into a block with the c++ EventEmitter. I'm going to rewrite the library with a getKeyState type function. Then I'll figure out the events.

from robotjs.

fohara avatar fohara commented on September 26, 2024

@Thr1ve I haven't seen a node module, but there is libuiohook , which could probably be wrapped with nan (or something), similar to how robotjs itself is designed.

from robotjs.

mwagstaff avatar mwagstaff commented on September 26, 2024

+1. Built-in text expansion capabilities similar to AutoHotkey would be a massive benefit.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

@Thr1ve but RobotJS can get the mouse position currently.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

@fohara thanks for the link! I'll try this library and if it works well, I'll turn it into a node module. It would be very easy.

from robotjs.

fohara avatar fohara commented on September 26, 2024

@octalmage excellent. I was able to compile and run the demohook example (./configure --enable-demo) from the repo on OS X and it seemed to work well.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

Awesome! Can't wait to try it out.

from robotjs.

Thr1ve avatar Thr1ve commented on September 26, 2024

@octalmage Completely agree on the separate module thing; sorry if I implied otherwise! In my mind, there would be a really simple, small, and separate module that would solely listen for any keyboard / mouse events and then emit them as a events / streams / observables / whatever.
Second, there would be a layer ( also separate from robotjs; totally with you re: keeping hotkeys separate ) that could recognize key combinations / sequences and send the appropriate commands to robotjs. I would think we could easily bend/hack something like Mousetrap to work for this?

@fohara Thanks! Can't say I know how to make that work, but it looks like a good time to learn!

I've been dreaming of a javascript version of AutoHotkey for so long... major props to @octalmage for what he's done so far 👍

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

Gotcha! I for sure will to try to replace each AHK feature with Node.js modules. If libuiohook works out we'll have a great start for key listening. I'll keep y'all updated!

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

@fohara did you encounter this error?

hook_run [882]: Accessibility API is disabled!
Failed to enable access for assistive devices.

I tried adding it to the list of allowed accessibility apps, but that isn't helping.

from robotjs.

fohara avatar fohara commented on September 26, 2024

@octalmage ah yes, I did encounter that accessibility error. My short term solution was to add iTerm (or any terminal app) to the allowed list. There is probably a more intuitive way of granting permission for this, but I haven't looked into it yet.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

Ah gotcha. This system is so silly. I had to remove and re-add iterm2.

from robotjs.

fohara avatar fohara commented on September 26, 2024

@octalmage yeah, there must be a programmatic way to handle this. I remember seeing this before, I think with Sikuli perhaps. There was some flag that prompted permission for accessibility, I'll see if I can find it.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

This tool does it, we can look at the code:

https://github.com/jacobsalmela/tccutil

But yeah, libuiohook is so perfect. Just need to create an EventEmitter in V8 and we'll be good to go. Looking into this now.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

It looks like emitting events isn't very straight forward but I figured it out. Woohoo!

from robotjs.

fohara avatar fohara commented on September 26, 2024

@octalmage nice! Looking forward to seeing how the event emitting works for this.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

So I've made good progress on this, but the library outputs the copyright when it's included:

Do you think I should contact the author to see if it's ok to remove it? Or just remove it? I don't want to release the project with this copyright notice, it's ugly.

from robotjs.

fohara avatar fohara commented on September 26, 2024

@octalmage good news on the progress! Regarding the copyright notice, you should be able to suppress it by building the lib with the --enable-quiet config, if I'm understanding this correctly.

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

@fohara oh duh, thanks!

from robotjs.

IvoPereira avatar IvoPereira commented on September 26, 2024

Any updates on this @octalmage?

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

This isn't a priority at the moment, I wouldn't expect it anytime soon. Sorry!

from robotjs.

Venryx avatar Venryx commented on September 26, 2024

Looking for a replacement for AutoHotkey, and this is saddening... : (

  1. For now, I think I'm going to try using edge.js (http://tjanczuk.github.io/edge)) to embed C# code, which'll hook into the windows dll's for keyboard input, and trigger nodejs callbacks when they're pressed. (This should also be nice in case I want to migrate over more os-involved operations from my autohotkey scripts, like window manipulation)

  2. If that doesn't work/is too difficult, I'll see if I can use node-ffi (https://github.com/node-ffi/node-ffi) to interface with the windows dll's directly.

  3. If that doesn't work, I'll probably just use the input listener system that's already being used for this other nodejs automation repo: https://github.com/relipse/JsRoboKey

(Actually, I might just try using #3 to begin with; depends mostly on whether I can find some easy C# code to capture global hotkeys and send them back to nodejs.)

Anyway, I'll post back here with my results! (Since this is a pretty significant feature for an automation system)

P.S. I realize the approaches above (#1 and #2 anyway) would be Windows-only solutions, so would probably not be wanted as a part/listed-dependency for this project. And that you already have something of a solution using nw.js. But I figured it'd be helpful to at least provide one path of adding hotkeys for other Windows users browsing these threads and not seeing a way explained yet. (I looked briefly at the nw.js project, and didn't see the way you captured hotkeys using it)

from robotjs.

octalmage avatar octalmage commented on September 26, 2024

Check out:

https://github.com/electron/electron/blob/master/docs/api/global-shortcut.md

https://github.com/nwjs/nw.js/wiki/shortcut

I use both of these in different apps and they work great for my purpose!

from robotjs.

Venryx avatar Venryx commented on September 26, 2024

Thanks for making the iohook library WilixLead!

Unfortunately, I'm getting an error trying to use it: wilix-team/iohook#16

from robotjs.

Venryx avatar Venryx commented on September 26, 2024

I also tried this very similar package: https://github.com/ayoubserti/node-iohook

But it also had an error, while installing. In that case, it's because I didn't have the Visual C++ Build Tools installed. I didn't feel like restarting, and installing the build tools, to try the module out. (at least while other options existed)

Which brings me to my third attempt: https://github.com/tomzx/gkm

This one finally works! However, it's not preferred, since it uses Java; but for Windows users, it's probably the easiest option atm. (at least, if you can't get the iohook or node-iohook libraries working)

from robotjs.

Venryx avatar Venryx commented on September 26, 2024

It would be nice to have a Wiki page listing various libraries that work well with robotjs, for achieving various automation functions.

If it's okay with @octalmage, I've gone ahead and created the page here: https://github.com/octalmage/robotjs/wiki/Plugins-(or-compatible-modules)

I plan to create some modules myself later, as I'd like to eventually replace AutoHotkey entirely. (AutoHotkey is nice, but it's scripting language is terrible)

from robotjs.

mviens avatar mviens commented on September 26, 2024

Venryx,

This is also a goal of mine. Love what AHK can do, but hate AHK's language. Plus version 2 has been in development for 6+ years. And even if/when that is released, it does not really fix the language issues, but mostly remove the horrible Command syntax in favor of function() syntax.

I have wanted to use JS for years to replace my product which is written in AHK. I plan to use NodeJS, TypeScript, Electron and Aurelia, but since I have a full-time job this conversion goes very slowly. I would really enjoying partnering with anyone here on replacing AHK with a cross-platform equivalent.

If interested, please contact me directly at [email protected].

from robotjs.

Venryx avatar Venryx commented on September 26, 2024

Hi mviens.

I have the same goal, however I've come to believe it's best to build such a system incrementally, based on the foundation here in robotjs. This is because robotjs already has a userbase, and the language/build-process is good, so we can just build up modules around it.

For example, I plan to make a module which creates a system-icon at the bottom-right of screen, from which the user can start, stop, or edit a given script file.

I plan to make another which adds the ability to query, move, and otherwise control various windows. So for example, an easy way to check the title of the active window, minimize it, etc.

We could build a new system from the ground up, but because the NodeJS module system is so flexible (and because gaining traction for a new software system is so hard), I think it's best to just build on this project here (robotjs) and transform it into the full-fledged software we want.

By the way, node-ffi is very convenient for hooking into native dll functions. You can do so entirely in JS land! (Even callbacks; I've used it to implement a full-fledged JS keyboard hook, which I now use everyday for global hotkeys. An old capture: https://github.com/Venryx/vdm-window-manager/blob/333f7d1284fbfbea92e4903b4a5a50ebbab685ea/Source/Input/HotkeyManager.ts)

from robotjs.

mviens avatar mviens commented on September 26, 2024

What does this project (https://github.com/octalmage/robotjs) plan on doing differently than the already built/working project (https://github.com/robot/robot-js)? It seems like the other project has not been updated in a while, does appears to be well thought out and capable.

from robotjs.

hallss93 avatar hallss93 commented on September 26, 2024

Use RobotJS to troubleshoot Electron's GlobalShortcut.
Use shortcuts for numerals (0-9) but as keys not issued plus values when pressed.
A solution to instantiate the keyTap shortly after an event capture:
globalShortcut.register ('6', () => { that.logger = "" + that.logger + 6 robot.keyTap ("numpad_6"); })

So a solution to use as a Global Shortcut! :)

from robotjs.

oktapodia avatar oktapodia commented on September 26, 2024

This issue has been closed because it has been inactive for > 180 days.
You may reopen this issue if it has been closed in error.

from robotjs.

denolfe avatar denolfe commented on September 26, 2024

For anyone looking for AutoHotkey-like expansion, I've found Espanso to be a good replacement.

from robotjs.

BaseMax avatar BaseMax commented on September 26, 2024

any updates?

from robotjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.