Command line script interacting with GUI program - windows

I'm trying to build a command line script to automate a process. Most of the script is straight forward, but there is one part where I need to convert a file from one format to another.
Unfortunately, the starting format is propriety and only one Windows software program supports this file type, and that program is only controllable via a GUI.
What I need to do in the GUI is simple:
open the program (if it is not already open)
file > open > [file]
(let file fully load)
file > export> xml > uncompressed > export > [give name] > save
(wait until finished)
(proceed)
Is there a way to work a GUI program into a command line script? How would I start? Would I need a dedicated computer that no one uses for this process?

Yes, there is a way to power a GUI program from a script: autohotkey (AHK). In short - though this summary trivializes its power - think of AHK as a way to send keyboard shortcuts to Windows and the program:
Windows + R to open the Windows Run... dialog
Type: program and press Enter
Seize Window of program
Alt + F to open File menu
etc...
So, you write an AHK script to do the Windows interaction, and you invoke autohotkey with that .ahk file as part of your pipeline.
As for needing a dedicated computer? I'd recommend it. But, if you have just one metal box, spin yourself up a VM and run your pipeline inside of that -- that leaves the primary OS available for interaction, while the VM does the load lifting.

Related

How to automatically work around GUI on OS X/linux?

I have a non-open-source GUI program on OS X which has a menu button to open a file in one format (example.X), and another menu button to export a rendering of that file in another format (example.Y). This is not a conversion that could be done by myself or by any other tool I've found, as the rendering involves extensive digital audio synthesis.
I have a folder of 100 files of type X, and I want a convenient way to convert each .X file into a .Y file without manually opening and exporting each in the GUI. Literally just two simple commands which don't require interfacing with the GUI - one to open the file, and another to render it out.
Is there a general way to achieve the effect of opening a program, running some commands from the menu, and then exit via the command line?
Thanks!

easiest way to create free standing Mac OS X perl applications

This may be a basic question. I have written a small perl script to run on a Mac running OS X which can be called from the finder by double clicking in the normal way. The file is executable and contains starts with #!/usr/bin/perl and input and output is via the clipboard. This all works but automatically opens a terminal window which the user must then close once execution is finished.
Is there an easy way to run this program as an application without opening a terminal? Can one do this with the native OS X perl? Or do I need to download something? Since the program will also be used by other users, the simpler the solution to better.
With the application "AppleScript Editor" : open it
Copy/paste this script
tell me to path to resource "this Name.pl" in directory "Scripts"
do shell script (quoted form of POSIX path of the result)
In the first line, change the name "this Name.pl" by the name of your perl file.
Save as --> Application
In the Finder :
Copy your perl file (executable) to the folder "/Contents/Resources/Scripts" of the created application
For Win32/Linux/or Mac use http://www.cavapackager.com/
If you're distributing your application to others, Platypus includes an installer to build free-standing apps around scripts.
Platypus supports Perl, Python, PHP, Ruby, Swift, Expect, Tcl, AppleScript or any other user-specified interpreter. It is free, open-source software distributed under the terms of the three-clause BSD license. It can run silently (without opening a terminal window, as you require), or can display graphical feedback of script execution as progress bar, text window with script output, droplet, WebKit HTML rendering or status item menu.

open console (terminal) window and execute command (rsync) on os x

I am from a windows background and trying to help a mac user friend to backup her pictures, docs, etc. onto an external drive. In windows, I would accomplish this by creating a simple batch file with an xcopy command and have a shortcut on the desktop that pointed to that .bat file when double clicked. However, in the mac world I am having significant trouble finding how to do this. I have searched repeatedly to find the mac equivalent, but all I find are sites saying things like "there are so many options on a mac - use one of them." However, none have ever given a specific solution nor pointed to a specific solution. Anyone here know of a specific step by step process to accomplish this? I simply want to be able to have her double click an icon on the desktop and have it copy her personal documents (not application settings or other overhead) to her external hard drive. Any help would be appreciated.
Create the batch file, which is usually called a shell script.
Enter all the commands that you want to run.
Set the executable bit, this is done with chmod +x path-to-the-file in Terminal.
Show info for the script and set Terminal to the application which should open it.
However, what I've done in similar situations and that I would recommend that you do is that I've created a shell script and instead of using Terminal I've initiated it from an AppleScript application. You can of course embed the entire shell script in the AppleScript as well. Basically it will look something like the following:
on run
do shell script "rsync -av ~/Pictures /Volume/Backup"
end run
Repeat the do shell ... line for each folder that you want to copy, or call the shell script itself. Then use AppleScript Editor which is included with Mac OS X and save it as an actual application.

Full screen through batch command?

I have a batch script under Windows. When anyone will click on that script I want the command window to become full screen like we do by keyboard shortcut [Alt+Enter].
Can it be done automatically using any command in batch file?
In Windows XP, you need to start your program maximized (but not full screen) via "start /max" as follows:
start "Winow Title" /MAX "C:\batches\myfile.bat"
This command would be inside your original batch file, and call the real bath file.
I don't think there's a way to change the full screen-ness of an executing "cmd" command from within a batch file absent someone writing a special app to do so by emulating sending Alt+Enter to the parent process.
In Windows 7 (and probably Vista) you must run inside XP virtual machine for full screen mode.
There is none. You can write a small program doing so for you, though. There is the SetConsoleDisplayMode function.

Automatically Position Application Window Using Command File in Windows

I'm using PuTTY to access my BSD file server and I have several terminal windows open at once. I wrote a simple command file to automate opening the terminal windows and I'd like to know if it is possible to place them at a specific location.
I have two monitors and as it is now, I have to manually drag the terminal windows over to my second monitor.
AFAIK you can't do it directly from a batch file without using some 3rd party software like AutoHotkey.
It makes it incredibly easy to move a window. For example this script would start Calculator and move it to the top-left corner:
Run, calc.exe
WinWait, Calculator
WinMove, 0, 0
You can also easily compile your script into an .exe if you want to share it with other people that don't have AHK installed. It will basically answer all your automation needs, just as it has done mine :)

Resources