I want to create a new text file by right click -> New -> New text document using AutoHotKey. How do I do this? I am new to AutoHotKey.
Edit:
Using Autohotkey, you can assign shortcut for some tasks such as running a particular program like Notepad. You do so by writing scripts. You can find the details on the Autohotkey website. I want to write a keyboard shortcut to manually automate the "right click -> New -> New text document" functionality.
I figured out that it could be done by adding the following script to to AutohotKey's existing script.
^+t::
Click, right, 1024, 355 (or any other mouse co-ordinates for that matter)
Send w
Send t
return
However, this syntax wouldn't work when I tried. Could someone tell me what's wrong and tell how should be the correct syntax?
As Ken White said you already have that built in Windows Explorer, Right click > New > New Text Document, so it's kinda pointless having another one doing the same thing.
However, if you want to use AutoHotKey to create a new text file more efficiently and faster then i would recommend this script
SetTitleMatchMode RegEx
MsgBox, 64, NewTextFile, USAGE: When in a folder in Windows Explorer press Ctrl + Shift + T to create empty text file.`nIf you press multiple times, multiple files will be created (e.g. NewTextFile0.txt, NewTextFile1.txt)
#IfWinActive ahk_class ExploreWClass|CabinetWClass
^+t::
NewTextFile()
return
#IfWinActive
NewTextFile()
{
WinGetText, full_path, A
StringSplit, word_array, full_path, `n
Loop, %word_array0%
{
IfInString, word_array%A_Index%, Address
{
full_path := word_array%A_Index%
break
}
}
full_path := RegExReplace(full_path, "^Address: ", "")
StringReplace, full_path, full_path, `r, , all
IfInString full_path, \
{
NoFile = 0
Loop
{
IfExist %full_path%\NewTextFile%NoFile%.txt
NoFile++
else
break
}
FileAppend, ,%full_path%\NewTextFile%NoFile%.txt
}
else
{
return
}
}
When you have this running and you are in a folder using Windows Explorer (or Desktop) press Ctrl+Shift+T to create New text files, as many as you'd like.
https://github.com/ilirb/ahk-scripts/blob/master/executable/source/NewTextFile.ahk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With