Page 1 of 1

Templates for new files?

Posted: 09 Sep 2018 13:18
by John_C
I'm working a lot with AutoHotkey and AsciiDoctor.

I have "New AutoHotkey Script.ahk" and "New AsciiDoctor Document.adoc" in NewItems folder.

Here is what I have inside "New AutoHotkey Script.ahk":

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
These lines are recommeded for each new script.

"New AsciiDoctor Document.adoc" also have some contents. However, when I create new AutoHotkey or new AsciiDoctor file with XYplorer's context menu, this file is blank.

Is there a way to preserve text from original file? I.e., each time I create AutoHotkey script in XYplorer, this script should contain the lines posted above?

Re: Templates for new files?

Posted: 09 Sep 2018 13:43
by highend
The original context menu from XY "New Items" does nothing more than creating a copy of that "<new file.some extension>" in the current folder...

Output of:

Code: Select all

text report("{size bb} | {name}<crlf>", quicksearch("/f", "<xydata>\NewItems", "|"));
?

Re: Templates for new files?

Posted: 09 Sep 2018 13:57
by John_C
@highend

Code: Select all

86 bytes | New AsciiDoctor Document.adoc
251 bytes | New AutoHotkey Script.ahk
0 bytes | New Excel Worksheet.xlsx
0 bytes | New Text Document.txt
0 bytes | New Word Document.docx

Re: Templates for new files?

Posted: 09 Sep 2018 14:36
by highend
and now a full screenshot of the context menu item you're clicking on +

Code: Select all

text <curpath>;

Re: Templates for new files?

Posted: 09 Sep 2018 14:49
by John_C
highend wrote:and now a full screenshot of the context menu item you're clicking on +

Code: Select all

text <curpath>;
"text <curpath>;" output:

Code: Select all

C:\Test
Screenshot:
context_menu.png
(It's a custom context menu, created based on another thread: viewtopic.php?f=7&t=19331&start=15#p161674)

Re: Templates for new files?

Posted: 09 Sep 2018 14:54
by RalphM
So did you create your own context menu?
Usually that stuff is supposed to show up under the "New Items" entry.

Re: Templates for new files?

Posted: 09 Sep 2018 15:00
by jupe
Since that is a custom context menu you have to make it work in your script by using the [source] parameter of new(), or a similar solution.

PS: If you had of kept the standard context menu, it would work out of the box, as it does when done via,
Edit | New Items | - submenu -

Re: Templates for new files?

Posted: 09 Sep 2018 17:30
by John_C
Well, I fixed it. Here is an updated version of Highend's script:

viewtopic.php?f=7&t=19331&p=161905#p161905