5

我想通过右键单击 -> 新建 -> 使用 AutoHotKey 新建文本文档来创建一个新的文本文件。我该怎么做呢?我是 AutoHotKey 的新手。

编辑:

使用 Autohotkey,您可以为某些任务分配快捷方式,例如运行记事本等特定程序。您可以通过编写脚本来做到这一点。您可以在 Autohotkey 网站上找到详细信息。我想编写一个键盘快捷键来手动自动化“右键单击->新建->新建文本文档”功能。

我发现可以通过将以下脚本添加到 AutohotKey 的现有脚本来完成。

^+t::
  Click, right, 1024, 355 (or any other mouse co-ordinates for that matter)
  Send w
  Send t
 return

但是,当我尝试时,这种语法不起作用。有人可以告诉我出了什么问题并告诉我应该如何使用正确的语法吗?

4

1 回答 1

3

正如 Ken White 所说,您已经在 Windows 资源管理器中内置了它,右键单击 > 新建 > 新建文本文档,所以让另一个人做同样的事情有点毫无意义。

但是,如果您想使用 AutoHotKey 更有效、更快地创建新的文本文件,那么我会推荐这个脚本

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

当你运行它并且你在使用 Windows 资源管理器(或桌面)的文件夹中时,按 Ctrl+Shift+T 来创建新的文本文件,只要你愿意。

https://github.com/ilirb/ahk-scripts/blob/master/executable/source/NewTextFile.ahk

于 2013-04-20T11:46:32.160 回答