Create hotstrings from variables

Get help with using AutoHotkey and its commands and hotkeys
User avatar
JnLlnd
Posts: 227
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Create hotstrings from variables

09 Aug 2017, 14:10

Hi,

Is is possible to create hotstrings with the abbreviations and expanded value stored in variables? I need to store hotstrings in an ini file and retrieve/enable them from the ini file. I would need a command similar to the "Hotkey" command as illustrated in the example below. Without such a "Hotstring" command, is there another way to obtain the same result?

This is a working example. It will create an ini file named with with the script's filenname.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

I've found this solution but it works only for uncompiled scripts. Mine is compiled.

I've also reviewed this solution but it seems quite invasive (it triggers every key of your keyboard).

Thanks.
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
User avatar
Nextron
Posts: 1020
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Create hotstrings from variables

09 Aug 2017, 15:02

JnLlnd wrote:I've also reviewed this solution but it seems quite invasive (it triggers every key of your keyboard).

Still, Dynamic Hotstrings was the first thing that came to mind. Creating a hotkey for every key is not so different from the native hotstring method. Both use a keyboard hook which triggers on each key event. Dynamic Hotstrings is just an additional layer on top of that hook. The downside is that it's cumbersome to implement regular hotkeys in the same script.
The more I know:
The more I know,
I know nothing.
User avatar
JnLlnd
Posts: 227
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Create hotstrings from variables

09 Aug 2017, 15:20

Nextron wrote:The downside is that it's cumbersome to implement regular hotkeys in the same script.

Hum. Interesting. The issue is that my script is already pretty complex to maintain regarding hotkeys. It supports hotkeys from variables (configurable in the GUI and stored in the app's ini file) and conditional hotkeys with #If (the function called for the hotkey may vary depend on the class of the windows on which it was executed).
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
Guest

Re: Create hotstrings from variables

09 Aug 2017, 16:51

First there is nothing wrong with redistributing a (renamed) autohotkey.exe for the sole purpose of hotstrings (the INI generates a ahk script, your program starts the renamed autohotkey and presto bob's your uncle - a good example of this technique is Catena by Normand Lamoureux http://normandlamoureux.com/catena/
(the catana exe is just a renamed autohotkey.exe (basic version) - so simply launch it as a plugin)

Second, just you could roll your own using a loop + input, lifted from lintalist (simplified) - perhaps I cut a few corners but you get the idea, check the Input examples in the Docs as well

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
JnLlnd
Posts: 227
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Create hotstrings from variables

09 Aug 2017, 21:53

Guest wrote:First there is nothing wrong with redistributing a (renamed) autohotkey.exe for the sole purpose of hotstrings (the INI generates a ahk script, your program starts the renamed autohotkey and presto bob's your uncle - a good example of this technique is Catena by Normand Lamoureux http://normandlamoureux.com/catena/
(the catana exe is just a renamed autohotkey.exe (basic version) - so simply launch it as a plugin)

Yes, this is a simple solution. My script would need a way to close the external script when exiting. Possibly using WinClose in OnExit.

Guest wrote:Second, just you could roll your own using a loop + input, lifted from lintalist (simplified) - perhaps I cut a few corners but you get the idea, check the Input examples in the Docs as well

Interesting too. In this example, the Tab in Alt+Tab is also triggering the hotstring expansion. But this is close to a working solution.

Thanks.
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)
Guest

Re: Create hotstrings from variables

10 Aug 2017, 03:59

Just deleted / forgot to copy some lines no doubt. You also need to take into account window switching, start typing in one window, switch to another window and continue to type could trigger it. But you'll figure it out :-0
User avatar
Nextron
Posts: 1020
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Create hotstrings from variables

10 Aug 2017, 10:06

JnLlnd wrote:
Guest wrote:First there is nothing wrong with redistributing a (renamed) autohotkey.exe for the sole purpose of hotstrings (the INI generates a ahk script, your program starts the renamed autohotkey and presto bob's your uncle - a good example of this technique is Catena by Normand Lamoureux http://normandlamoureux.com/catena/
(the catana exe is just a renamed autohotkey.exe (basic version) - so simply launch it as a plugin)

Yes, this is a simple solution. My script would need a way to close the external script when exiting. Possibly using WinClose in OnExit.

I'd have the script itself take care of closing itself if it's parent ceases to exist. If the parent process crashes, you can end up with multiple child processes.
You can then use ExecScript() to spawn a process without writing your dynamically generated hotstring script to hard disk. Then include the following to have it end itself when needed:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

The more I know:
The more I know,
I know nothing.
User avatar
JnLlnd
Posts: 227
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada

Re: Create hotstrings from variables

10 Aug 2017, 19:00

Nextron wrote:I'd have the script itself take care of closing itself if it's parent ceases to exist. If the parent process crashes, you can end up with multiple child processes.
You can then use ExecScript() to spawn a process without writing your dynamically generated hotstring script to hard disk


Yes. Good suggestion. In the following line, I guess "AutoHotkey.exe" would have to be replaced with the new name of the exe file (as suggested earlier).
exec := shell.Exec("MyAutoHotkey.exe /ErrorStdOut *")
Author of freeware apps Quick Access Popup (http://www.quickaccesspopup.com),
FoldersPopup and CSV Buddy (http://code.jeanlalonde.ca)

Return to “Ask For Help”

Who is online

Users browsing this forum: [Shambles], Bing [Bot], Capn Odin, Nexor8bit and 43 guests