# autotext / hotstrings / textexpander

## Recommended Posts

I switched almost all my scripts from autohotkey to autoit a year ago and I don't regret it

I still have an active autohotkey script with all my autotext phrases

p.e.

#If (A_ComputerName = "PCNAME")
:?*:\\me::myname@domain.com

etc

Is there a no way to switch them also to autoit?

Edited by remin

##### Share on other sites

remin,

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

remin,

M23

Hi Melba,

Maybe we can delete this thread and go on in the other thread?

(btw I still haven't resolved this autotext thing)

Remin

##### Share on other sites

remin,

Now we are here let us stay here.

What problems are you having with the 2 solutions I offered in the other thread:

- 1. Use a variable to contain the expanded text:

; Declare the content
$sEM = "myname@domain.com" ; And use it like this$url = $sEM & "\section\item.html"$url will then hold myname@domain.comsectionitem.html

-2. Use the Abbrev manager in SciTE4AutoIt3 to create an abbreviation which you can expand as you type. Look under the <Help - SciTE Help - SciTE4AutoIt3 - User Abbreviations> and <Help - SciTE Help - Extra Utilities - Abbrev Manager> to learn more. If you do not have the full SciTE4AutoIt3 package I highly recommend that you download it from here - you get lots of helpful utilities to help you code in AutoIt.

M23

P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

I wish all moderators in other forums were so nice as you are.

ConsoleWrite("example because of trigger: " & $hotstring & @CRLF) EndFunc Gr, Mana #### Share this post ##### Link to post ##### Share on other sites Thanks Manadar This works great. Now I can put all hotstrings in one function: #include <HotString.au3> HotStringSet("\\hi", example) HotStringSet("\\btw", example) While 1 Sleep(100) WEnd Func example($hotstring)
local $lengte = StringLen($hotstring)
Send("{BACKSPACE " & $lengte & "}") If$hotstring = "\\hi"  then
Send("hello")
EndIf
If $hotstring = "\\btw" then Send("by the way") EndIf EndFunc Have you thought to add also the expanded text in HotStringSet? Like this: #include <HotString.au3> Dim$arguments[2]
$arguments[0] = "hello"$arguments[1] = "by the way"

HotStringSet("\\hi", example($arguments[0])) HotStringSet("\\btw", example($arguments[1]))

While 1
Sleep(100)
WEnd

Func example($hotstring,$arguments)
local $lengte = StringLen($hotstring)
Send("{BACKSPACE " & $lengte & "}") Send($arguments)
EndFunc

This makes the if/endif hotstring control unnecessary.

Edited by remin
• 1

##### Share on other sites

Nice job! I'm glad you like it.

The reason for doing it this way is to keep the functionality of this new feature similar to AutoIt's @HotKeyPressed macro. So when a programmer realizes HotKeySet won't be enough, he can replace HotKeySet with HotStringSet and use the first parameter of the function instead of @HotKeyPressed.

HotKeySet("a", "hotKeyCallback")
HotKeySet("b", "hotKeyCallback")

While 1
Sleep(500)
WEnd

Func hotKeyCallback()
Switch @HotKeyPressed
Case "a"
; Do 1
Case "b"
; Do 2
EndSwitch
EndFunc

Becomes

#include "HotStrings.au3"

HotStringSet("abc", "hotKeyCallback")
HotStringSet("def", "hotKeyCallback")

While 1
Sleep(500)
WEnd

Func hotKeyCallback($HotKeyPressed) Switch$HotKeyPressed
Case "abc"
; Do 1
Case "def"
; Do 2
EndSwitch
EndFunc

With only minor changes.

• 1

##### Share on other sites

This would still be possible but maybe the if/endif code is easier:

#include <HotString.au3>

Dim $arguments[2][2]$arguments[0][0] = "\\btw"
$arguments[0][1] = "by the way"$arguments[1][0] = "\\hi"
$arguments[1][1] = "hello" HotStringSet("\\hi", example) HotStringSet("\\btw", example) While 1 Sleep(100) WEnd Func example($hotstring)
local $lengte = StringLen($hotstring)
Send("{BACKSPACE " & $lengte & "}") For$i = 0 To UBound($arguments) - 1 if$arguments[$i][0] =$hotstring then
send($arguments[$i][1])
endif
Next
EndFunc
• 1

##### Share on other sites

Happy to replace now all my previous Autohotkey hotstrings to autoit

HotStringSet works great.

The only difference I noted is that the Autohotkey hotstrings expander is much faster comparing to the Autoit HotStringSet (maybe because they don't use the send command?)

and that it takes a bit more CPU during the text expanding in Autoit (5-6%), comparing to Autohotkey (0,5-1%)

But it is not a great problem.

Now I can use all my scripts in autoit.

##### Share on other sites

remin,

It looks as if the AHK implementation is in its core code, while HotStrings is a UDF, so it is hardly surprising that there is a speed and CPU load difference.

M23

• 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

Ah, actually, what surprised me the most. It's not the HotString UDF that is taking up any CPU at all, but rather Send that is taking up quite a bit (which is how I assume you tested it).

A quick test I made based on remin's example is this which takes up no (0%) cpu on my machine.

#include <HotString.au3>

HotStringSet("\\btw", "example")
HotStringSet("\\hi", "example")

HotStringSet("exit", "_exit")

While 1
Sleep(100)
WEnd

Func example($a) ConsoleWrite($a & @CRLF)
EndFunc   ;==>example

Func _exit()
Exit
EndFunc
• 1

##### Share on other sites

remin,

try playing with options SendKeyDelay and SendKeyDownDelay. This cut my CPU time in half and rather obviously made the typing insanely quick. Your mileage may vary.

Opt("SendKeyDelay", 0)
Opt("SendKeyDownDelay", 1)

Send("I think Halo is a pretty cool guy. Eh kills aleins and doesnt afraid of anything.")
Send("I think Halo is a pretty cool guy. Eh kills aleins and doesnt afraid of anything.")
Send("I think Halo is a pretty cool guy. Eh kills aleins and doesnt afraid of anything.")

##### Share on other sites

ConsoleWrite() doesn't seem to work on my pc.

Nothing happens.

What did I wrong?

Edited by remin

## Create an account

Register a new account

×

• Wiki

• Back

• Git