Jump to content

autotext / hotstrings / textexpander


Go to solution Solved by jvanegmond,

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
Link to comment
Share on other sites

  • Moderators

remin,

I though we had already discussed this in >your post in this thread and my subsequent reply? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

remin,

Now we are here let us stay here. :)

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

 

- 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. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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

Thanks for answering.

$url will then hold myname@domain.com\section\item.html

I don't know what to do with a variable like this ;)

What I want to do is writing p.e. "!me" which has te expand to "myname@domain.com"

Last year I installed SciTE, looked in the help file, these abbreviations are only for the SciTe editor isn't it?

Link to comment
Share on other sites

  • Moderators

remin,

Gosh, thanks. :>

So you want to expand text in other apps? Then take a look at Manadar's HotStrings UDF. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Yes! Thank you Melba that is what I want.

Do you know if it is possible to give an argument to the function to avoid to create a function for every hostring?

p.e.

HotStringSet("\\btw", example(1))
HotStringSet("\\ty", example(2))

Func example()
    Send("{BACKSPACE "activation_stringlength"}")
    Send("By the way") ;Send argument 1
    Send("Thank you") ;Send argument 2
EndFunc
Link to comment
Share on other sites

  • Moderators

remin,

I have never used the function so I cannot really comment - perhaps you would be better posting in the HotStrings thread itself. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

remin,

It is Manadar's UDF - so you will have to wait until he is on-line. Just wait patiently until he pops in. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. And also bear in mind that what is important to you is not necessarily so to others. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Solution

Hi remin,

This wasn't possible. However, it is now. Please get the latest hotstring UDF from my github and try this:

#include "hotstring.au3"

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

While 1
    Sleep(100)
WEnd

Func example($hotstring)
    ConsoleWrite("example because of trigger: " & $hotstring & @CRLF)
EndFunc

Gr,

Mana

Link to comment
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
Link to comment
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.

Edited by Manadar
Link to comment
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
Link to comment
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. :)

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
Edited by Manadar
Link to comment
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)

WinActivate("Untitled - Notepad")
WinWaitActive("Untitled - Notepad")

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.")
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...