Write to New File Created By Notepad In Lua - winapi

I'm aiming to open a new .txt file in Notepad and then write to it. Since the file I'm opening (notepad.exe) isn't the same file I want to write to (the new .txt file), I'm unaware of how I can write to the file. Here's the code I have so far:
local list = io.popen("notepad.exe","w")
print(list)
list:write("Tester")
list:flush()
Notepad is opened, but the text isn't written to the new file because the code is trying to edit notepad.exe instead.
What can I do to be able to edit the new opened .txt file? I don't want to actually save the file anywhere, so that's why I'm aiming to just put text in an untitled .txt file. Thanks in advance :)

Notepad does not respond console input.
You must find edit control on notepad's window and PostMessage keypressing event to it.
Or prepare temporary file and load it:
local list = io.open("newfile.txt","w")
list:write("Tester")
list:close()
os.execute("notepad.exe newfile.txt")

Related

How to save opened text file in autohtokey

What is the way of saving open .txt file in autohotkey. Let say you have opened text file test.txt; and you would like to close it or close it with saving any edits that you have made to that file.
I'm unable to find any method on the internet/doc. It can be a simple #1:: hotkey. It's part of larger script and this is just for testing.
Thanks xDD

Can a batch file write to a hidden notepad file?

Some context:
I have an Excel Macro (.xlsm) file I've created for my company, which I'm creating a batch file for that copies it from a Network folder to a local folder for each computer/user profile that clicks the batch file. What I'm looking to do is for every user that runs the batch file, I want to append their name to a hidden notepad file in the same network folder of the original macro file. That way, whenever I revise/fix/add features to the macro, I'll have a list of all the users that are using the macro file, so I can send an email letting them know of the updates.
Note: I know how to obtain the username of the user that runs the files.
I know that you can write and append to Notepad files using a batch file, but I can't find a source that verifies whether it's possible to write to an existing hidden Notepad file. I came upon this post in my search, but that's using the C# language.
So, my question(s) are:
Can a batch file write/append to a hidden notepad file?
If so, would I use the same syntax/method that you would when writing to a visible (non-hidden) file?
If not, would could I go about this feat? Could I temporarily unhide a hidden file, append to it, then rehide it? Or should I go about it using a different method?
Is this a good method, or is there a more efficient/better way to accomplish this (keeping a list of users that have the macro file)?
You could use stream redirection operator >> and system variable with login as i recall %username%. Do echo %username%>>hiddenfile. txt

vbscript encoded file (vbe) not properly working after adding plain vbs

I have encoded vbs(vbe) and plain vbs in one file (.vbe) I create this file programmatically with the help of other .vbs script.
For some reason, when it is created programmatically- (.vbe) file doesnt work. BUT When I open it in notepad and add just a simple space, save it and run again- vbe works perfectly. What can be the reason for that?
Also if I manually copy the code from the opened .vbe and then create in ANSI format new .vbe and paste there my code- it works also as well

Open an already opened (by others) Excel file with BATCH

I have a BATCH code, which perfectly opens an EXCEL file:
START "C:\office\excel.exe" "C:\tmp\file.xlsx"
BUT: If someone else opens this EXCEL file (via network) and do not close it --> he leaves it opened, then I cannot open this file using my BATCH.
If I click on the EXCEL file, and press ENTER (so opening using windows not batch), the file will be opened, but it alerts me that someone else is locked this file, but I can open it to read or I can request a notice if the other person closes the file.
How could I set in BATCH file, to open the EXCEL (or WORD) file (only for reading) even if it is opened by others (via network)?
The solution is: leave the START command:
"C:\office\excel.exe" "C:\tmp\file.xlsx"

to directly download txt file?

How to configure Firefox such that whenever a link to a txt file is clicked, this txt file will directly got downloaded to the local file system, without asking user what you want to do with the file and where you want to save this file to?
It seems that in the Firefox's Application Panel, there is no entry for txt file although I've already clicked a link to a txt file.
Thanks.
if you press ALT while you click on the link it should just save the link, so in your case it will just save the .txt file. Hope this helps!

Resources