以.AHK作为扩展名的文件是AutoHotkey 脚本(AutoHotkey Script)文件。AutoHotKey脚本文件是 AutoHotkey 使用的纯文本文件类型,AutoHotkey是一种用于在(AutoHotkey)Windows中自动执行任务的免费脚本工具。AutoHotkey软件可以使用.AHK 文件来实现自动化。可以轻松地自动执行诸如单击窗口提示、键入字母和数字等任务。
有时AutoHotkey脚本还包含热键(键盘快捷键)和热字串,它们可以在键入时自动替换某些文本字符串。如果我们举个例子来解释,就像我们手机上的SpellChecker和AutoCorrect一样。(AutoCorrect)在本文中,我们将学习如何在Windows 10中使用(Windows 10)AutoHotKey将这些 .AHK 文件转换为 .EXE 文件。
脚本有点像运行一系列命令并可以接受用户输入的小程序。它们主要用于自动化重复性任务。AutoHotKey脚本用途广泛。这些脚本非常有能力做一些基本的事情,比如重新映射键,更复杂的操作,比如重命名和/或移动文件和创建目录,主要像批处理脚本,但更重要的是,这些脚本有它们的小众功能,并且在Windows上很流行。
将 AHK 文件转换为 EXE 文件
现在,要转换AHK文件,您需要下载 AutoHotkey应用程序并将其安装在您的系统上。有两种方法可以轻松转换文件。
- 使用 Ahk2Exe 进行 AutoHotKey
- 使用命令提示符
1] 使用 Ahk2Exe 进行 AutoHotKey
我们知道运行AutoHotKey脚本非常难以执行,但最好将它们作为可执行文件运行。
- 转到开始菜单并打开Convert .ahk to .exe。
- 在Required Parameters部分,单击Browse for Source (script file)。
- 选择要转换为可执行 .EXE 文件的.AHK文件。(.AHK)
- 现在单击Browse for Destination (.exe 文件)(Destination (.exe file))。
- 选择转换后要保存文件的文件夹。确保(Make)在选择目的地时输入文件名。(File Name)
- 点击转换(Convert)。
您可以从某些可选参数(Optional Parameters)中进行选择,例如选择自定义图标文件和编码方法。
阅读(Read):如何将 DXF 转换为 GCode(convert DXF to GCode)。
2]使用命令提示符
使用命令提示符(Command Prompt)进行日常工作是一件真正的事情,您了解事情是如何工作的。要使用命令提示符转换脚本,您仍然需要在系统上安装AutoHotKey应用程序。
转到开始菜单,键入cmd ,然后以管理员(Administrator)身份打开命令提示符(Command Prompt)。
使用以下命令导航到AutoHotKey应用程序文件夹:
cd C:\Program Files\AutoHotkey\Compiler
输入(Enter)以下命令来转换文件:
Ahk2Exe.exe /in "location of file with filename.ahk" /out "location of file with filename.exe"
要将文件与新图标一起转换,请使用以下命令:
Ahk2Exe.exe /in "location of file with filename.ahk" /out "location of file with filename.exe" /icon "location of icon"
确保(Make)在位置中包含文件名及其文件扩展名。
要了解有关如何使用AutoHotKey脚本及其转换的更多信息,您可以使用该应用程序或在此处阅读(read it here)。该应用程序和网站还介绍了如何创建 .AHK 脚本的方法。
如果您尝试转换任何安全文件夹中存在的任何.AHK文件,此过程可能会引发错误。即使命令提示符(Command Prompt)在管理员(Administrator)模式下运行,您也需要将脚本文件移动到允许读/写操作的位置。
如果您转换的 EXE 文件不起作用,请确保脚本文件没有错误并且语法正确。(If your converted EXE file is not working then make sure the script file has no errors and is syntactically correct.)
阅读(Read):如何将 WMA 转换为 MP3(Convert WMA to MP3)文件格式。
How to convert an .AHK file into an .EXE file in Windows 10
Files that end up with the .AHK as an extension is an AutoHotkey Script file. AutoHotKey script file is a plain text file type that’s used by AutoHotkey, a free scripting tool for automating tasks in Windows. The AutoHotkey software can use the .AHK files to automate things. One can easily automate tasks like clicking window prompt, typing letters and numbers, etc.
Sometimes AutoHotkey scripts also contain hotkeys (keyboard shortcuts) and hotstrings, which can automatically replace certain text strings when typing. If we take an example to explain, it’s just like SpellChecker and AutoCorrect on our phones. In this article, we will learn how to convert these .AHK file into an .EXE file using AutoHotKey in Windows 10.
Scripts are somewhat like small programs that run a series of commands and can accept input from a user. They’re mostly used to automate repetitive tasks. AutoHotKey scripts have a wide range of uses. These scripts are quite capable of something basic like remapping keys, to more complex operations like renaming and/or moving files and creating directories, Mostly like batch scripts but more then it, these scripts have their niche function and are popular on Windows.
Convert AHK file to EXE file
Now, to convert AHK files you need to download the AutoHotkey application and install it on your system. There are two ways by which you can easily convert the files.
- Using Ahk2Exe for AutoHotKey
- Using Command Prompt
1] Using Ahk2Exe for AutoHotKey
We know that running AutoHotKey scripts is pretty difficult to execute but it is way better to run them as an executable.
- Go to the Start Menu and open up Convert .ahk to .exe.
- In the Required Parameters section, click on Browse for Source (script file).
- Select the .AHK file you want to convert to an executable .EXE file.
- Now click on Browse for Destination (.exe file).
- Select the folder where you want to keep the file after conversion. Make sure to enter the File Name while choosing the destination.
- Click on Convert.
You can choose from certain Optional Parameters like choosing custom icon files and encoding methods.
Read: How to convert DXF to GCode.
2] Using Command Prompt
Using Command Prompt for day to day work is a real deal, you understand how things work. For converting scripts using the command prompt, you still need the AutoHotKey application installed on your system.
Go to start menu, type cmd, and open Command Prompt as Administrator.
Navigate to AutoHotKey application folder using:
cd C:\Program Files\AutoHotkey\Compiler
Enter the following command to convert the file:
Ahk2Exe.exe /in "location of file with filename.ahk" /out "location of file with filename.exe"
To convert the file along with a new icon, use the following command:
Ahk2Exe.exe /in "location of file with filename.ahk" /out "location of file with filename.exe" /icon "location of icon"
Make sure to include file names in the location along with their file extension.
To know more about how to use AutoHotKey scripts and their conversions, you can use the application or read it here. The application and website also cover the method of how you can create .AHK script.
If you are trying to convert any .AHK file which is present in any secured folder, this process may throw an error. Even if Command Prompt is running in Administrator mode, you need to move the script file to the position where read/write operations are allowed.
If your converted EXE file is not working then make sure the script file has no errors and is syntactically correct.
Read: How to Convert WMA to MP3 file format.