I have many scripts written in python which use the pywinauto library. These scripts are opening programs on Windows, doing things within them, etc. Now that I’ve begun to learn Node.js, I have only found so far Robot.js, which is certainly promising but lacks the ability I think to get into the nitty-gritty details like pywinauto does.
For example, suppose I wanted to locate a program called “Wordperfect” if it was open or not and if open, kill the program and reopen it. Here’s how I am doing that in python using pywinauto:
from pywinauto import Desktop, Application # Starts Wordperfect wp_open = "wpwin14.exe" in (p.name() for p in psutil.process_iter()) if wp_open == False: # detects Wordperfect is closed app = Application().start(cmd_line=u'"C:\Program Files (x86)\Corel\WordPerfect Office X4\Programs\wpwin14.exe" ') if wp_open == True: # detects Wordperfect is open app = Application().connect(class_name='WordPerfect.14.00') # title=u'WordPerfect X4 - Document1 (unmodified)', wordperfect = app[u'WordPerfect.14.00'] # Kills Wordperfect app.Kill_() # Reopens Wordperfect app = Application().start(cmd_line=u'"C:\Program Files (x86)\Corel\WordPerfect Office X4\Programs\wpwin14.exe" ')
This is just the beginning of my script. It becomes much more complex from here. Unfortunately, so far I have not found a specific way to do this within Node.js. Can anyone let me know if there is and how to do it? I’ve been checking out child-process
in the Node.js documentation but from what I saw in the examples, it’s not clear how to recreate what I have in python above.
Advertisement
Answer
Ultimately I found Robot.js which does the same thing on windows except create a bundle of EXE.