I have a huge LISP project, I've made a prv file that permits to the VLIDE to compile this project into a single vlx file (it compiles also the fas file). The problem is that it is not possible to compile the project from outside the autocad or from command prompt so I cannot automate the vlx building using a script.
The question is: is there any way to do this? Can I compile fas-vlx from outside the autocad? Or can I launch autocad giving a script that compiles the prv and then closes the autocad?
You have to launch AutoCAD, but even so it gets tricky as it requires the use of undocumented functions.
Be warned this is a bit of a Rube Goldberg. but it works!
I will be demonstrating with Autocad 2014.
First you will need to make an Autocad Script file that contains some undocumented commands. I named mine build.scr
(Note that vlisp-compile-list is not documented anywhere. If you do find some documentation please let me know!)
vlide
(
vlisp-compile-list
'st
(
list
(strcat (getenv "UserProfile") "\\Documents\\AutocadFiles\\gui.lsp"))
...
)
(strcat (getenv "UserProfile") "\\Documents\\AutocadFiles\\CompiledLisp.fas")
)
Then make a batch file that contains this:
#echo off
cd c:\Program Files\Autodesk\AutoCAD 2014
start acad.exe /b build.scr
It starts AutoCAD and runs the specified script
next you will need to Download and install AutoHotKey
and build a script like this for it:
Run, BuildLisp.bat
sleep, 30000
WinActivate, Autodesk AutoCAD 2014 - [Drawing1.dwg]
WinActivate, Visual LISP for AutoCAD <Drawing1.dwg>
WinActivate, Autodesk AutoCAD 2014 - [Drawing1.dwg]
sleep, 10000
WinClose, Autodesk AutoCAD 2014 - [Drawing1.dwg]
When you activate this script. It should open AutoCAD and build all of your LSP files into a single .FAS then close.
Somethings to Note. The Visual LISP editor must be open to compile, The compile will only happen when window activation occurs.
If anyone finds a better way. PLEASE Let me know!
After some tests here I could finally make it a bit more faster and easy to use.
At command line, call autocad with some startup switches. You'll need an empty drawing, call it dummy.dwg. The /b stands for the script you'll run:
"C:\Program Files\Autodesk\AutoCAD 2019\acad.exe" "C:\somefolder\dummy.dwg" /nologo /nossm /b "C:\somefolder\CompileLispProjects.scr"
Inside .scr file:
;;MAKE VLISP OPEN BUT LET AUTOCAD ACTIVE. YOU NEED VLISP OPEN TO LOAD VLISP-* FUNCTIONS
(C:VLIDE T)
;; TRY TO RUN VLISP-MAKE-PROJECT FUNCTION
(setq errobj (vl-catch-all-apply 'function-which-will-use-vlisp-make-project-fas))
;; IF ANY ERROR COMES OUT, STOP AND ALERT
(if (vl-catch-all-error-p errobj)
(progn
(princ "\n***ERROR COMPILING SOMETHING***\n")
(princ (vl-catch-all-error-message errobj))
(princ)
);_progn
;; ALL GOOD, QUIT AUTOCAD
(progn
;; THERE'S A SAFE LOCK IN QUIT COMMAND, SO SAVE A DUMMY FILE AND QUIT AGAIN WITH IT SAVED
(command-s "._QUIT" "_N" "")
(command-s "._QUIT" "")
);_progn
);_if
;; IT'S IMPORTANT TO HAVE THE LAST LINE EMPTY (<ENTER>)
The trick in that code is the (C:VLIDE T). It's not documented and I've found it because I know AutoLISP has a lot of undocumented functions. Try it with nil too, you'll see that VisualLISP will be the active window, locking your AutoCAD to execute the next commands (and so you'll need to click somewhere in AutoCAD to activate its window and make the code to run properly).
Note: When AutoCAD is closing, maybe your VisualLISP window will hold for a while, don't try to activate it. Let it be for few seconds and it'll close by itself.
Related
I can't figure out how to start the OneNote UWA from Windows command-line. The best I could do is find where it's installed. However, I don't know how to actually start it up from the command-line; as, the executables in that directory don't start OneNote UWA.
C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11901.20096.0_x64__8wekyb3d8bbwe
PS: I tried to use the same command-line that's in Windows TaskManager (below). However, the app doesn't startup nor does it give an error; even with elevated privileges.
"C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11901.20096.0_x64__8wekyb3d8bbwe\onenoteim.exe" -ServerName:microsoft.onenoteim.AppXxqb9ypsz6cs1w07e1pmjy4ww4dy9tpqr.mca
I'd really appreciate any help suggestions to do this. If this is not possible (or nobody knows the answer, I would also be happy if someone knows how to associate a global hotkey to OneNote UWA.
I followed this tutorial and it worked great for me:
Launch Metro app from command line
my resultant command was this:
explorer.exe shell:AppsFolder\Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim
which launched into OneNote (metro/winrt/uwa version and not the desktop version)
There is a shortcut you can do that would have worked in my case. When you look at the target of the shortcut you create... instead use this command line tool to get the full target (since you can't copy from the target box in the shortcut properties window) and then use this instead:
explorer.exe shell:<target value>
get the command line tool here:
LNK file parser
careful though because the value wraps when you use the LNK file parser in a command window. You can output the result text from lnk_parser_cmd to a text file to ensure you get the correct value. Their example is:
lnk_parser_cmd.exe shortcut.lnk
you would simply use:
lnk_parser_cmd.exe shortcut.lnk > result.txt
and then you can easily copy and paste the non-wrapped text from result.txt.
I have to interact with Windows software projects for work but I like to do most of my programming in Emacs. I'm using emacs for Windows. I want to be able to switch to a Neotree buffer, and open the file at the point in an external app. An example would be a pdf file in Adobe or a project file in Visual Studio.
I'm not fluent enough in elisp to make my own command to do this, and I'm wondering if there is an easy way to either hook into Neotree or write some custom function to open the file externally.
I know I can open the current buffer file in an external app, I just don't know how to do it in Neotree (Which I have integrated with Projectile)
Any help would be appreciated.
Use the following:
(defun neotree-open-file-in-system-application ()
(interactive)
(shell-command (concat "start " (neo-buffer--get-filename-current-line))))
This overwrites the Neotree's default function. In the original neotree.el file they use the following code:
(defcustom neo-default-system-application "xdg-open"
"Name of the application that is used to open a file under point.
By default it is xdg-open."
:type 'string
:group 'neotree)
(defun neotree-open-file-in-system-application ()
"Open a file under point in the system application."
(interactive)
(call-process neo-default-system-application nil 0 nil
(neo-buffer--get-filename-current-line)))
I have tried changing the "xdg-open" to "start" , "start ","start-process" etc. but none of them worked. Replacing the call-process in the original function with a simple shell-command + file path seems to do the trick.
Note: Since we have overwritten the original function, all the shortcuts still work. Default shortcut to open a file with the default app is "o".
I would like to set emacs as the default editor for text files when I double-click open them in Windows.
However I would like to open them asa buffer in the same running instance of emacs (i.e. frame) , if any.
Right now the behaviour will open another instance of emacs (i.e. another emacs frame).
Does anyone know which specification in init.el would allow this behaviour?
I've been using this guy's approach, which is an alternative to adding entries to the registry. I've reproduced his steps here:
Create the following batch file 'runemacsclientw.bat'.
::::::::::::::::::::::::::::::::::::::::::::::::::
:::
::: Emacsclient startup script runemacsclientw.bat
::: Robert Adesam, robert#adesam.se
::: http://www.adesam.se/robert/
:::
::: N.B. Alot of this is reused from other Emacs
::: users that have published stuff on the
::: Internet. Thank you! :)
::::::::::::::::::::::::::::::::::::::::::::::::::
#echo off
:: Emacs binaries...
set binpath=c:\Program Files\emacs\bin
:: If no arg is given set filename to c:\
if "%~1"=="" (
set filename=c:\
) else (
set filename=%~1
)
:: Run Emacsclient
"%binpath%\emacsclientw.exe" --no-wait --alternate-editor="%binpath%\runemacs.exe" "%filename%"
Convert the bat file to exe with a bat to exe converter
Choose batch file.
Check 'invisible application'.
Under 'version information' select an icon (if you want to make it purdy)
Compile and exit.
Copy 'runemacsclientw.bat' to .../emacs/bin.
Associate file types with runemacsclientw.bat.
Add (server-start) to init file.
Change owner of ~/.emacs.d/server (in %appdata%) to the current user (it will default to local administrator). This removes the "unsafe directory ~/.emacs.d/server" warning.
First have a quick look at emacsclient documentation.
Then in your init.el file start the emacsclient server by running:
(server-start)
Next we'll add some keys to the registry which gives an "Edit with Emacs" option in the context menu for all files.
Add the following keys:
[HKEY_CLASSES_ROOT*\shell\Emacs]
#="Edit with Emacs"
[HKEY_CLASSES_ROOT*\shell\Emacs\command]
#="c:\Program Files (x86)\emacs-23.2\bin\emacsclientw.exe" --no-wait --alternate-editor="c:/Program Files (x86)/emacs-23.2/bin/runemacs.exe" "%1"
The quotes are literal and should be included. You may have to play with the paths a bit so that they fit your environment.
As for the double-click behavior it's a matter of knowing which registry keys to add. If you know that they you should be able to generalize this answer to the behavior you want.
The program emacsclient will blast the file into a running copy of emacs (provided you ran 'server-start') or if there is not an existing copy it will run the command supplied with the "alternate-editor" option.
How do I change the message that comes up automaticly when I start up CMD? The one where it says:"
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation.
How do I change that automatic message?..
By editing the cmd.exe. :) (That was a joke btw, don't really try that) If you look at a the cmd.exe in a hex editor, you will see that text in it. There is no easy way that I know of to change it.
Here is an ugly hack to emulate what you are wanting. First create a .cmd file that contains the following:
cmd /k init.bat
(cmd /k tells the computer to start an instance of cmd and run the parameter and not exit)
Then created your init.bat file with the following:
#echo off
cls
echo My message goes here
Then you just run your .cmd file instead of cmd.exe and you will get a command window with just your text at the top.
If I knew why you were wanting to do this, then maybe my answer could have been more specific to your needs.
You have to reverse engineer it :) Don't remember exactly how I did, but using a debugger single step until you find the place where it prints that out and edit it. I "hacked" it a bit more and it refuses doing anything, saying "do it yourself!" :)
I'm experimenting with Gambit scheme and I have problem! My OS is Windows 7.
When I try to interpret script I do:
gsi.exe myscript.scm
This works, but GSI's console window is shown and closed just after script finished. I can't see results my program prints! I may do (read-line) at the end, but... when I try to compile with GSC.exe the behaviour is the same: it opens console window, does something, prints about errors and closes it immediately - I can't read something! In this case I can't even do (read-line) hack, you see. How can I view what Gambit writes?
This doesn't works, though:
gsc.exe 1.scm > 1.txt
You should run Gambit in an existing terminal window. Open up your terminal first, and then run Gambit. When Gambit terminates, your terminal will be still up.
Create a batch file with the commands. Set the properties on the batch file such that the window doesn't close after executing(right click, properties on the batch file's icon).
You can always, add "pause" at the end of the bath file, to keep the window open.
Alternatively, just open a DOSBOX box, and run the script from there. The box will remain open when the scrip completes.
UPDATE
terminal
To open a terminal(Command Prompt, DOS Box,etc.) use the [Start] button. Enter cmd in the "Run" field.
This will open a terminal with a command line interpreter. You can run gsc or gsi from there.
batch files
Here is the sample program hello.scm:
(display "HELLO WORLD")
(newline)
Method 1--using pause. This example is only for calling binary executable(.EXE) files such as gsc, or gsi.exe:
#echo off
gsi hello.scm
pause
Method 2--using cmd /k. The pause method (above) is preferred as this starts another cmd shell:
#echo off
cmd /k gsi hello.scm
properties
Sorry, setting the "Close on exit" property of a command apparently only exists for true DOS commands via .pif files.
To the same end right-click hello.scm, then associate it with cmd /k gsi hello.scm.
Any of the above batch files may be modified to take a filename argument (as %1, or %* for all args) and run gsc %1 instead of gsc hello.scm. After making the batch file generic in this way, associate the .SCM extension with it.
Associate .SCM with run-gsi.bat:
#echo off
gsi %*
pause