Templates for new files?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
John_C
Posts: 336
Joined: 16 May 2018 20:04

Templates for new files?

Post 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?

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Templates for new files?

Post 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", "|"));
?
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Templates for new files?

Post 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

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Templates for new files?

Post by highend »

and now a full screenshot of the context menu item you're clicking on +

Code: Select all

text <curpath>;
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Templates for new files?

Post 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)
To see the attached files, you need to log into the forum.

RalphM
Posts: 2122
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Templates for new files?

Post by RalphM »

So did you create your own context menu?
Usually that stuff is supposed to show up under the "New Items" entry.
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Templates for new files?

Post 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 -

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Templates for new files?

Post 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

Post Reply