RobotJS – Node.js Desktop Automation
github.com
github.com
I use it for window management (which is it awesome at, especially considering I have a very complex arrangement with a 4K monitor + laptop screen), automatic mute when not home, remapping shortcuts, and more.
The config syntax is pretty simple and works great. There are some really cool ones all over the internet. Here's mine: https://github.com/STRML/init/blob/master/hammerspoon/init.l...
Hammerspoon Docs: http://www.hammerspoon.org/docs/
Having an equivalent tool on the Mac would be awesome, as I don't think anything in AutoHotkey's class exists right now...
My only initial concern from reading the quick start (http://www.sikulix.com/quickstart.html) is the apparent requirements to use the "SikuliX IDE" for scripting...
I've used it a few times in the past and was able to use an external screenshot program (Apple-Shift-4 on Mac) and a text editor to write the scripts.
https://github.com/octalmage/mDesktop
With RobotJS and nw.js I've been able to port many of my apps to JavaScript, and ultimately make them cross platform.
I'm really glad to see a replacement for AutoIt and AHK and potentially, if not already, cross-platform too.
I can't speak for AHK but AutoIt has made huge progress over the last couple of years. Jon has been working on new features, especially improved COM support.
Maybe RobotJS will have a community too? It'd be great to see UDF's and a thriving ecosystem.
AutoHotkey has also improved a bunch recently. Lexikos picked up development and he's done a killer job. But unfortunately it (and AutoIt) will never be cross platform. That's why I made RobotJS.
I honestly never thought about a community but that's an amazing idea. A classic forum would be great, I've spent so much time on the AutoHotkey/AutoIt forums. I'd love for this to happen.
AutoHotkey is available and open source but the custom scripting language is off-putting, I would much rather have something like standard JavaScript for it. If this project moves forward in that direction it could be great.
AutoHotkey is avalible, but only on Windows. I don't think I would have made this if AutoHotkey was cross platform.
I hope you get inspired!
//Type "Hello World".
robot.typeString("Hello World");
//Press enter.
robot.keyTap("enter");
Whoever designed this interface didn't think much about consistency. keyboard.type('foo');
keyboard.press('fn');
... makes much more sense. > robot.keys("Type a string")
> robot.keys(ENTER) // ENTER is an integer key value
(I've been thinking about this while trying to make an idiomatic node client for Selenium WebDriver... https://github.com/hugs/34#api) > robot.keys.ENTER()
(Not great for key combos, though...) robot.keys.enter()
(since enter is a function, not a constant) and make it chainable by returning `robot.keys`. robot.keys.ctrl().enter()Java had this, like, forever. Long live "Write Once Run Anywhere"!
- the process list - list of the window positions - text under a cursor - provides an interface to create specialized keyboard/mouse actions for specific apps (because why stop at chrome?)
i'm sure this is project is going to be quite popular :)
example here: https://github.com/SchizoDuckie/DuckieTV/blob/angular/js/uti...
That's quite interesting! I thought node-webkit isn't suitable (yet) for such purpose. Could you go into more detail on how to do parsing/automation external sites with it?
Basically, you can use xmlhttp to fetch any webpage becaused of relaxed restrictions. then use DOMParser (a built-in browser component, that you can even shim) to create a virtual DOM of that xmlhttp result, and execute regular querySelector and querySelectorAlll queries on that :)
I wrote up some ideas about "aQuery -- Like jQuery for Accessibility", which RobotJS would be very useful for implementing. It refers to the Mac accessibility API but it could work with any platform, and even abstract the differences between platforms just like jQuery does.
http://www.donhopkins.com/mediawiki/index.php/AQuery
Also, Morgan Dixon did some wonderful stuff with Prefab: The Pixel-Based Reverse Engineering Toolkit, which would be great to integrate into RobotJS.
http://homes.cs.washington.edu/~mdixon/research/prefab/
aQuery -- like jQuery, but for selecting, querying and manipulating Mac app user interfaces via the Accessibility framework and protocols.
So you can write jQuery-like selectors that search for and select Accessibility objects, and then it provides a convenient high level API for doing all kinds of stuff with them. So you can write higher level plugin widgets with aQuery that use HTML with jQuery, or even other types of user interfaces like voice recognition/synthesis, video tracking, augmented reality, web services, etc!
For example, I want to click on a window and it will dynamically configure jQuery Pie Menus with the commands in the menu of a live Mac app. Or make a hypercard-like user interface builder that lets people drag buttons or commands out of Mac apps into their own stacks, and make special purpose simplified guis for controlling and integrating Mac apps.
[...]
aQuery could apply the DOM tree searching and traversal and data association stuff to the Accesibility Tree, which is similar in a lot of ways to a DOM tree, and describes all the widgets and user accessible affordances and commands in an app, as well as non-tree-like relationships between them (this label describes that widget, this tab represents that panel, this icon represents that view, this editor manipulates that object, etc).
[...]
aQuery should provide ways of registering patterns and calling handlers when user interface items that match them are created and destroyed. jQuery doesn't directly provide a way to do that (handling page onload events and XHR request responses is usually sufficient), but of course there is a jQuery plug-in that does it: https://code.google.com/p/mutation-summary/ .
So when some user interface objects you're interested in controlling come into existence, you can wrap them with your own "widget" to glue them into whatever other user interface you want to provide. (pie menus, hyperlook, ar, speech recognition, etc).
[...]
I think aQuery should be independent of jQuery, but I like to use jQuery as a metaphor for how it works, even though that might suggest that it's tied to jQuery, or even HTML, which it shouldn't be.
> 95.1% C
Any intention on making this available for other languages?
Node.js modules can be written in C or Javascript but implementing new features like this requires you to use C so there is no "making this available for other languages".
I never knew node modules could be written in C.
I would only implement the low level "hardware" primitives in C, then implement the high level API in JS like Chromium's Blink-in-JS initiative [2]. Once they start expanding the high level functionality, they will lose potential contributors by sticking with pure C.
[1] https://github.com/octalmage/robotjs/blob/master/src/robotjs...