Hotstringer, create hotstrings on the fly! (even for images and formated text)

Post your working scripts, libraries and tools for AHK v1.1 and older
leosouza85
Posts: 90
Joined: 22 Jul 2016, 16:28

Hotstringer, create hotstrings on the fly! (even for images and formated text)

Post by leosouza85 » 05 Aug 2022, 23:01

Hello, this is a very simple script that I have made.
You can make hotstrings on the fly, without doing any ahk code. The hotstrings created works even if you close and reopen the script.

Demonstration:


How to use:
1 - Select the object that you want to create a hotstring for (text, formatted text, images, files or folders).
2 - Press Control + 1
3 - Type the hotstring that you want (do not use normal words, because the word will transform into the thing that you want, use non existant words)
4 - Use the hotstring.

Code: Select all

#Noenv
#SingleInstance, Force
settitlematchmode, 2


^1::

filename = ""
send ^c

inputbox, filename, What HotString do you want to create?

if (filename != "") 
{
	FileDelete, %filename%.imt
	FileAppend, %ClipboardAll%, %filename%.imt

	Loop, read, %A_ScriptName%, corrige.ahk
	{
		if A_LoopReadLine contains `;65342758764698809%filename%
			continue
		else
   			FileAppend %A_LoopReadLine%`n
	}
	FileMove, corrige.ahk, %A_ScriptName%, 1

	textofuncao=
	(
		`r`n
		#IfWinNotActive What HotString `;65342758764698809%filename%
		:*:%filename%:: `;65342758764698809%filename%
		fileread, clipboard, *c %filename%.imt `;65342758764698809%filename%
		Send, ^v `;65342758764698809%filename%
		return `;65342758764698809%filename%
	)

	file := FileOpen(A_ScriptName,"a")
	file.write(textofuncao)
	file.close()
	reload
}
return

^2::

filename = ""

inputbox, filename, What HotString do you want to delete?

if (filename != "") 
{
	FileDelete, %filename%.imt
	Loop, read, %A_ScriptName%, corrige.ahk
	{
		if A_LoopReadLine contains `;65342758764698809%filename%
			continue
		else
			FileAppend %A_LoopReadLine%`n
	}
	FileMove, corrige.ahk, %A_ScriptName%, 1
}
return

^3::reload
^9::ExitApp



leosouza85
Posts: 90
Joined: 22 Jul 2016, 16:28

Re: Hotstringer, create hotstrings on the fly! (even for images and formated text)

Post by leosouza85 » 09 Aug 2022, 22:15

V2 - Released

ChangeLog:
- Control + 2 to delete a Hotstring
- If you create a hotstring that already exists (in the script), it will overwrite it
- The code will not execute if you leave the inputbox blank
- Hotstrings will not be triggered on the script's inputbox


Post Reply

Return to “Scripts and Functions (v1)”