Menu Close

AutoHotkey Open text input window and save contents. (Storing and reading the value in InputBox)

Today is an InputBox function that is useful for creating macros with Auto Hotkey. The input box is a function that the input window appears, where the contents of the macro can be changed with the input value, and it can be applied in a flexible manner such as changing the operation mode.

    Auto Hotkey Input Box Examples and Explanations

This is the simplest and most basic way to use an input box.

InputBox,InputText,BoxName
MsgBox %InputText%

first 'InputBox' To start the command, and then 'InputText' In the section, 'BoxName' Specify the name of the message window (or at least).

Then the text in the message box 'InputText' Is stored as a variable named '%InputText%' So you can recall the saved text. E.g 'Send, %InputText%' It is possible to make the input text less.

However, this method flips variable values when the corresponding AutoHockey file containing the code is turned off. Because of this, there is an application method to store text documents at specific locations.

InputBox,InputText,BoxName
FileAppend,%InputText%,C:\InputSave.txt

like this 'FileAppend' , And then specify the storage path, file name, and extension name of the file.

However, if you use this method, every time you write the contents in the input box, you will continue to write to the previous text. If you want to clear the previous text and save it as a new value each time, you can write the code as follows.

InputBox,InputText,BoxName
FileDelete,C:\InputSave.txt
FileAppend,%InputText%,C:\InputSave.txt

Immediately 'FileDelete' If you specify a path, file name, or extension, the existing text document is deleted and a new one is created.

Finally, this is an example that actually loads the values stored in the text document.

FileRead,InputText,C:\InputSave.txt
Clipboard=%InputText%

Like this 'FileRead' , You can declare that you want to read the document, then code the value of the variable, the path of the file to read, and invoke it with the variable value as well. As an example 'Clipboard=%InputText%' It reads the stored value from the document and copies it to the clipboard. In this state, pressing 'Ctrl + v' will output the value as it is.

With these methods, you can freely save a document or variable in the input box, link it to a macro, or save and recall text. Put the numbers in the input box, 'FileRead' You can specify the behavior according to the number you read through, and it is a useful feature that you can use indefinitely.

Leave a Reply

Your email address will not be published.

Posted in AutoHotkey, All

이메일 구독 - Email Subs

최선을 다해 직접 만든 콘텐츠만 공유합니다.
We share the best content we have created.