Possible Autoit-like JavaScript macros?

℡╲_俬逩灬. 提交于 2019-12-10 19:57:36

问题


The title says it all. Is there a way to write macros in JavaScript to achieve a similar functionality to that of Autoit? I just would want to manipulate files on my own computer (offline) and could easily do it with autoit, but since I am currently learning JavaScript -- plan to develop in Node.js -- I figure it wouldn't hurt to get the extra practice.

Thanks guys!


回答1:


Use an application which supports JavaScript as a shell scripting language, such as the following:

  • JsRoboKey
  • PowershellJS
  • PowerChakra
  • RemoteNodeJS
  • JScript + WSH
  • JavaScript Shell Scripting with JSC
  • QtScript: QScriptEngine
  • Part I: How to Choose a JavaScript Engine for iOS and Android Development - OpenAphid-Engine



回答2:


nodejs has a module which do autoit things --

nodejs install autoit

var au = require('autoit');

au.Init();
au.Run("notepad.exe");
au.WinWait("[Class:Notepad]");
au.Send("Hello, autoit & nodejs!");



回答3:


NodeJS is a very powerfull platform, it is extensible and opensource. There is no problem to run local scripts to do everything you need using JavaScript (see standard FileSystem library docs). You can also try to look in NPM(NodeJS package manager).




回答4:


Javascript can't write to a file on your local machine remotely.. Its almost the same as HTML in a view model.

It can however perform some executions of other scripts via AJAX for example. But thats on server again. It might be worth a look to read on server && client side differences.

im not 100% sure but node might offer another outlet on this but it would still be server side.. Not locally.

The Server - This party is responsible for serving pages and handling the logic | Code behind.

The Client - This party requests pages from the Server, and displays them to the user. On most cases, the client is a web browser.

The User - The user uses the Client in order to surf the web, fill in forms, watch videos online, etc.




回答5:


Assuming you have AutoIt installed (say in folder C:\AU3) and this folder in the PATH, you can add extension '.AU3' to the PATHEXT environment variable, and create an AutoIt script called, say, hello.au3 with just a silly line:

MsgBox(0, "Warning", "Hello, World!")

Now, simply typing the command 'hello' will execute the script, displaying the silly message in a modal message box.

Next, create an equally silly Node.js script, say, MyWarn.js - in the same folder:

var oCP = require("child_process");
console.log("Starting...");
var oNP = oCP.execSync("hello");
console.log("Done.");

Assuming Node is also in the PATH, try this command:

node MyWarn

So ... we get the benefits of Node (for its jit), and the benefits of AutoIt (for its GUI handling.) The problem is getting the two to communicate. Personally, I use a RamDisk to pass small files...



来源:https://stackoverflow.com/questions/20685768/possible-autoit-like-javascript-macros

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!