NEdit_How to use the Shell on NEdit to save the file - LINUX base - linux

I am working on the script on NEdit with LINUX environment.
But I can't reach one of the funciton of the script.
*I would like to add "save" file function at the script, but it seems not possible.
I checked the NEdit Help document, it mentions the "Make Backup Copy" function is UNIX only.
Not sure anyone has experience on it? -> To automatically save/backup the file after you call the script with LINUX environment.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Make Backup Copy
On Save, write a backup copy of the file as it existed before the Save command with the extension .bck (Unix only).
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
https://www.doc.ic.ac.uk/lab/labman/nedit/n6.html

Are you using the macros or the functions?
save() just saves the current file (same as Ctrl-S)
save_as_dialog() will bring up a dialogue to save the file
You can put them in buttons from the macro menus or you can define a functions and then add that function to a macro button.

Related

How does File Explorer open files?

It's maybe stupid question, but what happens behind the scenes when i double click the word app, or .exe app?
For 'Non-Developer' it just opens the file in right environment after doubleclicking. But I would like to know, how is it done, how can the file manager know what to open? (.docx in word, .txt in texteditor,etc...)
+ I would like to know how can I do that in Node.js, is it the best way to use child_process and if statements for every suffixes?
There is a file association to tell Windows how to treat a certain file extension. You can type assoc in a Windows Command Prompt to see them. As an example:
C:\test>assoc .txt
.txt=txtfile
So Windows knows now, that the file with the extension .txt is a txtfile.
ftype defines, how that filetype is to be handled:
C:\test>ftype txtfile
txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1
So whenever you doubleclick on a file, Windows checks if it is associated with any filetype. Then it looks up, how to handle that filetype and executes that command (in the example above, it opens Notepad with the filename as a parameter).
Both assoc and ftype are able to change the settings (for example to open .txt files with another editor). But if you try that, do yourself a favor and note the original settings, so you are able to revert your changes when needed.
The changes can also be done directly in the registry (not recommended, when you are not experienced in handling the registry)
For Node.js, you can use child_process to shell out to the start command which does similar things as the File Explorer.
E.g. start some/path/to/file.docx will open that file in the default program associated with the format.

Automate "Right-click + Print" on .xlsx files

I need to automate the act of printing .xlsx file.
I have already seen some answers to this task saying that it is possible by creating a VBA script, as well as some examples. That is not about what my question revolves around.
Thought, I know that it is also possible to right-click on a .xlsx file and click "Print", which does the exact task that I want. It opens Excel, prints the file to the default printer, then closes Excel. (Windows 7, by the way)
So I'm thinking that the work has already been done here.
What process is launched when clicking this "Print" option? Can it be launched via command line, or "clicked" by a python script or something? And if not, why? How can something so easy to click be impossible to automate? I assume a process of some sort must be launched in some way.
Found it!
This task can be easily launched using python.
import os
os.startfile('C:/path/to/the/file.xlsx','print')
This code will launch the same print task. From there, it is pretty trivial for a python developer to automate the task in his scripts.
However, if you do not know much about Python and do not want to learn it now, an easy (or lazy?) way to add it in any automation script would be to save the two lines of code above in a whatever.py file, and launch it via command line (with Python installed, of course).
The context menu print command for Office documents utilizes Dynamic Data Exchange (DDE) and does not directly run a command that can be replicated from the command line.
You can view the content of the commands in the registry. Browse to HKEY_CLASSES_ROOT\.xlsx and look at the (Default) data column. On my machine, "Excel.Sheet.12" is the type of a .xslx file. Then browse to HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\ to see the commands registered for that file type. On my machine, the Print (Default) is "C:\Program Files\Microsoft Office\Office16\EXCEL.EXE" /dde and the "command" is zn=BV5!!!!4!!!!MKKSkEXCELFiles>]-z5hw$l[8QeZZR4_X=$ /dde, none of which is directly useful or accessible for running from a command line.
It will require another program to allow you to access the interface, but there are programs that allow you to make use of DDE from the command line. I recommend Freddy Vulto's Class Exec. More information and a few other similar utilities can be found here.

Change directory where is saved the AutoHotkey .exe file on Sublimetext3

I need to make my Autohotkey scripts run at startup, so I think the best way is to save the file .exe in the startup folder, but the .exe file is saved automatically in the same folder of the source, so save the source in the startup folder could be a solution too, but it also opens the source at startup.
Now I'm using the syntax highlight plugin for autohotkey in SublimeText3, but I don't know if there are some way to save the .exe file to a different folder than the one where the source (I'm a noob in informatic).
I'd tried using SetWorkingDir in the Autohotkey script and costumizing the AutoHotkey.sublime-build file using working_dir, but I don't know how they work, so I didn't achieve the goal.
I need a way to edit .ahk with Sublimetext3, keeping my scripts in "documents" and, when I build, save the exe in another folder.
If you're just looking to have your AHK files load when you start up Windows, then the Startup folder is indeed the right location. An elegant solution would be to call the other scripts from this main script.
Since the default AutoHotkey.ahk script is contained in your Documents folder, you can include or run various other AHK scripts, depending on whether you want them to run under one AutoHotkey instance, as one per script, or some combination of the two.
Documentation on Include is fairly solid. The example from the linked page:
#Include C:\My Documents\Scripts\Utility Subroutines.ahk
#Include %A_ScriptDir% ; Changes the working directory for subsequent #Includes and FileInstalls.
#Include C:\My Scripts ; Same as above but for an explicitly named directory.
Similarly, you can Run like below:
Run, C:\My Documents\Scripts\Utility Subroutines.ahk
I am not sure I understood well your question. (Maybe you could make it clearer)
To run an .ahk at startup you can save it in your startup folder and you need simply to associate .ahk with the AutoHotkey.exe. (Always open with AutoHotkey.exe). You don't have to have the 2 files in the same location.
You could also add a shortcut to your .ahk file to your startup folder.
If you have many scripts copy each shortcuts to the startup folder.

AppleScript Replace File

I'd like to write an AppleScript for replacing three system files with ones I've modified. I'd like to do this with an AppleScript instead of manually replacing them because I'll have to replace three files every time there's an OS X update. Specifically, I'll be replacing stock graphics drivers with ones I've modified to support a graphics card which is connected via Thunderbolt. Is it possible to write an AppleScript for replacing one file with another? I ask because I know that when you replace a file, a dialog pops up with three options, and I don't know how to address that.
You can do this with Finder:
set freshFile to choose file
tell application "Finder"
move freshFile to desktop replacing yes
end tell
All you need to do is work out the source and destination paths to completely automate the script.
Many scripters do not like working with Finder, for a variety of reasons. If you want something that is incredibly fast, you would use the do shell script inside of your AppleScript:
do shell script " mv -f ~/Desktop/ArlandaTilUppsala.pdf ~/Documents/Employ.pdf"

Trying to append the Excel file through unix via command prompt

What needs to be done?
I need to make a connection to the remote machine through UNIX, go to the shared drive, open an excel file, save it and close it. This needs to written in an script.
The file contains macros so they needs to be opened manually on daily basis, save it and close it. We plan to write a script that would run on daily basis and refresh this file automatically.
Where am i facing the issue?
Making a connection to the remote machine is done, after that i run certains commands:
1. Open the command prompt
2. cd the file path
3. Open the File
Now this is where the issue starts
How to save the file automatically?
How to close that file?
I tried using the taskill option and it almost worked but it gives out the popup of Do you want to save the file and i dont know how to provide output to that popup through command prompt.
Let me know if you have any idea on how to move ahead on this.
A bit hackish, but xdotool, a program which simulates mouse clicks and keyboard presses could be used. If Windows is being used, then see this question for tools which simulate mouse clicks and keyboard presses.
Have you tried SendKeys?
That may help.

Resources