Jump to content

HotStrings - String hotkeys


jvanegmond
 Share

Recommended Posts

Manadar,

Thank you so much for developing and sharing this UDF. I was looking at another scripting language, which does something similar, but the overall syntax was so convoluted I did not want to use it even just for this feature. When I did a search on the AutoIt forum, I found exactly what I needed in a language which makes sense to me.

You have helped me so many times in the past and I wanted to let you know you've done it again.

I'm sure you are appreciated by many.

Thank you and Merry Christmas.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

  • 4 months later...

Excuse me.  I am a little confused about this thread...  What is the most updated version of this UDF?  Should I use the one in the first post?  I mean, is the first post updated or should I look for the last post with an UDF?  Thanks!!!

Update: I've been trying all versions but I don't get to make it work.  I copy the UDF in the same dir than the example script and I run it on Scite but I don't get any response.  The tray icon is running and no errors at all.  But I don't get any response when I type "callme" and press ENTER.

: What am I doing wrong?

Edited by Denik
Link to comment
Share on other sites

  • Moderators

Denik,

The code from the first post is what you need - I have just tested it with both the latest release and the latest Beta and it works perfectly. :)

Try running it this way: Copy the UDF code (the second code box) into SciTE, then copy the example (the first code box) - less the #include <HotString.au3> line - and paste it into SciTE after the UDF code. Now run the resulting script - does it work now? :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

Denik,

The code from the first post is what you need - I have just tested it with both the latest release and the latest Beta and it works perfectly. :)

Try running it this way: Copy the UDF code (the second code box) into SciTE, then copy the example (the first code box) - less the #include <HotString.au3> line - and paste it into SciTE after the UDF code. Now run the resulting script - does it work now? :huh:

M23

 

Thanks for your help, Melba, but still not working for me...  :(   I think I'm doing something wrong...  Am I supposed to type "callme" and press ENTER on any active window?  Because the only thing I can see is the tray icon that indicates that the program is running.  If I type the example hotstring "callme{ENTER}", for instance, into notepad while this program is running, should a messagebox appear?

By the way...  I'll take advantage of your contact to tell you what I'm traying to do and find out if I'm in the right way: I created a little GUI that has several "category" tabs and each tab has got several buttons.  Each button launches a different program or "command".  And I would like to add the option to launch these same commands through hotkeys instead of clicking buttons.  So, I would like these hotkeys were something like:

ctrl + category number + button number = e.g. CTRL+11 (in numpad)

The challenge for me is that I can't use hotkeyset because I need to press two or three keys but not at the same time but in sequence.  The same way we oftenly use to type an ASCII code (press ALT, type two or three numpad keys and release ALT), I would like to press e.g. CTRL, and to be able to type two or three numpad keys before releaseing the special key. 

I've tried the format {CTRLDOWN}[NUMPAD1}[NUMPAD1}{CTRLUP} but I don't get it to work with hotkeyset.

Any suggestion about it?

Thanks for your patience... :

Denik.

 

EDIT: I've created a separated topic for my question so I don't invade this thread:

Thanks.

Edited by Denik
Link to comment
Share on other sites

Thanks for your help, Melba, but still not working for me...  :(   I think I'm doing something wrong...  Am I supposed to type "callme" and press ENTER on any active window?  Because the only thing I can see is the tray icon that indicates that the program is running.  If I type the example hotstring "callme{ENTER}", for instance, into notepad while this program is running, should a messagebox appear?

 

UPDATE:

- If I replace the example hotstring by "callme" (without {enter} key) both UDF versions work fine for me (the one in post #1 and the one in post #17).

- While I use the post #1 UDF my problem seems to be with {enter} key as Minty mentioned in post #16.  If I use other different special keys like e.g. "{F4}" or "{CTRL}m" it works.  But I still don't get it to work with NUMPAD.  Not even with {NUM 1}, {NUM 2}, etc. nor in Send format: {NUMPAD1}, {NUMPAD2}, etc.

- While using the post #17 UDF none of the supported special keys work for me.  The "date" example it does.

Edited by Denik
Link to comment
Share on other sites

  • 2 weeks later...

Just pushed out a new version. Here's a mini changelog:

- Cleanup + tidy of code

- Added: HotStringSetDebug to enable/disable debug information

- Added: UDF style documentation

- Added: Small unit-test-like test project

- Fixed: Library now initializes upon first use of HotStringSet instead of wherever it happens to be included.

- Fixed: $tagKBDLLHOOKSTRUCT is only created when it is necessary in method _HotString_KeyProc.

This update was triggered by my desire to get rid of $hotString_hotkeys[1], $hotString_hotfuncs[1] mechanism as well as seeing if I could use function names directly instead of passing strings. On the first account I failed, on the second account it looks like it works fine automatically because Call also accepts a function reference. I left the use of Call in there so this library is backwards compatible with older AutoIt versions.

@Denik I replied to you in the topic you created in the General Help & Request forum.

Edited by Manadar
Link to comment
Share on other sites

I would like to point out that this udf has problems on a non-English Windows operating systems.
the problem is that the "supported keys" are localized on non-English versions of Windows. (strange but true).
In fact, for example, the following list contains a list of  some of the "codes" of special keys returned by Italian windows version.

so you have to take this into account when you pass the first parameter to the function HotStringSet()

English     Italian
----------------------------
{CAPSLOCK}  {BLOC MAIUS}
{SHIFT}     {MAIUSC}
{Left Windows}  {WINDOWS SINISTRO}
{SPACE}     {BARRA SPAZIATRICE}
{Application}   {APPLICAZIONE}
{Right Ctrl}    {CTRL (DESTRA)}
{LEFT}      {Freccia SINISTRA}
{UP}        {Freccia SU}
{RIGHT}     {Freccia DESTRA}
{DOWN}      {Freccia GIÙ}
{INSERT}    {INS}
{PGUP}      {PGSU}
{PGDOWN}    {PGGIÙ}
{DELETE}    {CANCELLA}
{Prnt Scrn} {STAMPA}
{SCROLL LOCK}   {BLOC SCORR}
{Pause}     {PAUSA}
{Num Lock}  {BLOC NUM}
{NUM DIVIDE}    {/ (Tn)}
{NUMMULT}   {* (Tn)}
{NUM SUB}   {- (Tn)}
{NUM 7}     {7 (Tn)}
{NUM 8}     {8 (Tn)}
{NUM 9}     {9 (Tn)}
{NUM PLUS}  {PIÙ (Tn)}
{NUM 4}     {4 (Tn)}
{NUM 5}     {5 (Tn)}
{NUM 6}     {6 (Tn)}
{NUM 1}     {1 (Tn)}
{NUM 2}     {2 (Tn)}
{NUM 3}     {3 (Tn)}
{NUM ENTER} {INVIO (TN)}
{NUM 0}     {0 (Tn)}
{NUM DECIMAL}   {. (Tn)}
Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Chimp, thanks for the report. I'd like to treat that behavior as a bug and try to fix this as soon as possible. The reasoning is that with the current behavior it is nearly impossible to use this UDF in any kind of software you intend to distribute to a computer and you don't know which language it is running.

Edit: I'll be tracking the issue here: https://github.com/jvanegmond/hotstrings/issues/1

Edited by Manadar
Link to comment
Share on other sites

  • 1 month later...

Hello Manadar,

Do you know if it is possible to pass an argument to the function in order to avoid creating 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

I tried this without success:

Dim $arguments[2]
$arguments[0] = "text1"
$arguments[1] = "text2"

HotStringSet("\\ar", examplefunction('1'))

While 1
    Sleep(10)
WEnd

Func examplefunction($str)
    MsgBox(0,"",$str)

    Send("{BACKSPACE 4}")
    Send($arguments[$str])
EndFunc

(it activates immediate the function without waiting the trigger text)

Link to comment
Share on other sites

I added this in my existing autoit file (where my other autoit scripts are):
 

HotStringSet("\\me", "examplefunction")

Func examplefunction(
    Send("{BACKSPACE 4}")
    Send("myemail@domain.com")
EndFunc

But all functions with a GUI and a while command, like this:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
       Case $.....

did not work anymore.

Did I something wrong?

Link to comment
Share on other sites

 

Hello Manadar,

Do you know if it is possible to pass an argument to the function in order to avoid creating 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

I tried this without success:

Dim $arguments[2]
$arguments[0] = "text1"
$arguments[1] = "text2"

HotStringSet("ar", examplefunction('1'))

While 1
    Sleep(10)
WEnd

Func examplefunction($str)
    MsgBox(0,"",$str)

    Send("{BACKSPACE 4}")
    Send($arguments[$str])
EndFunc

(it activates immediate the function without waiting the trigger text)

 

 Answered in the help request topic: '?do=embed' frameborder='0' data-embedContent>>

Edited by Manadar
Link to comment
Share on other sites

I added this in my existing autoit file (where my other autoit scripts are):

 

HotStringSet("\\me", "examplefunction")

Func examplefunction(
    Send("{BACKSPACE 4}")
    Send("myemail@domain.com")
EndFunc

But all functions with a GUI and a while command, like this:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
       Case $.....

did not work anymore.

Did I something wrong?

 

Can you create a reproducer? I'm not able to get the same behavior in my tests.

Here's what I tried:

#include "hotstring.au3"
#include <GUIConstantsEx.au3>

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

; Create a GUI with various controls.
Local $hGUI = GUICreate("Example")
Local $iOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $iOK
            ExitLoop

    EndSwitch
WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)


While 1
    Sleep(100)
WEnd

Func example($hotstring)
    ConsoleWrite("example because of trigger: " & $hotstring & @CRLF)
EndFunc
Link to comment
Share on other sites

Try this one:

#include <GUIConstantsEx.au3>
#include <HotString.au3>

HotKeySet("!1",  "Adresses")

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

While 1
    Sleep(100)
WEnd

Func Adresses()
 If WinExists("Address Menu") Then
   GUIDelete("Address Menu")
 EndIf


 $Form4=GUICreate("Address Menu", 215, 115, 265, 142)
 $lTextsetact  =   GUICtrlCreateLabel("Click = Put in Clipboard",   45,  10, 150, 25)
 $bFnaamR =        GUICtrlCreateButton("MyFirstName",               10,  35,  80, 25)
 $bFnaamA =        GUICtrlCreateButton("MyLastName",                10,  60,  80, 25)
 GUISetState(@SW_SHOW)

 While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
       Case $GUI_EVENT_CLOSE
         GUIDelete("Address Menu")
       Case $bFnaamR To $bFnaamA
       Switch $nMsg
          Case $bFnaamR
            ClipPut("MyFirstName")
          Case $bFnaamA
            ClipPut("MyLastName")
       EndSwitch
    EndSwitch
 WEnd
EndFunc ;==>Adressen

Func example()
    Send("{BACKSPACE 5}")
    Send("By the way")
EndFunc

Alt 1 ==> send string to clipboard

This doesn't work in above example.

If you comment out both HotStringSets it works fine.

Link to comment
Share on other sites

  • 3 months later...

Thanks dgm3333 for submitting a pull request to add a cool feature.

A maximum time has been added between keys. If you type part of your hotstring, take a coffee break, and come back to continue the hotstring sequence you'll now find it, as expected, does not trigger a hotstring. The default time is 1,5 seconds between key presses. This can be set by a global $hotStringMaxInterval

Link to comment
Share on other sites

  • 1 month later...

Hi, this code is very successful. However, I am having problems with Turkish characters. For example, the code does not work when two Turkish characters written side by side. For example, the "ışıldak" for the words ... I really need to make this work. Please help.

Thank you very much in advance.

Link to comment
Share on other sites

Hi falcontechnics,
 
Sorry the library isn't working. This is probably a known issue: https://github.com/jvanegmond/hotstrings/issues/1

If you set HotStringSetDebug(true) in your script and run your script from SciTe, you can see in the console output exactly what the library thinks it is receiving in terms of codes. If there are any special characters not being recognized, copy whatever is printed in the console to your HotStringSet function.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...