Page 1 of 1

Prevent hotstring from inputting actual text

Posted: 08 Jun 2018, 13:08
by Avastgard
I have made some hotstrings to open certain folders by typing certain keys. For example, if I want to open a folder called AutoHotkey, I will type AHK and press spacebar or Enter. The hotstrings will only work if Scroll Lock is toggled. Here is the script:

Code: Select all

#If GetKeyState("Scrolllock","T")

::ahk::
Run, "C:\Users\Username\AutoHotkey"
Return
The reason I chose this over a simple hotkey is that I have too many folders and use them quite often. I would soon run out of hotkeys to open each one. Besides, I find this method more intuitive, as not having to hunt for the folder I want with the mouse helps me keep focused.

Now what I would like to do is to prevent these hotstrings from actually editing text in a text editor, like Word or Trello. Like, if I'm in the middle of writing a document, I don't want to have to move the window out of focus just to type the hotstring without inserting "ahk " on the document itself, as that would defeat my purpose of being able to open the window I want imediately.

So, is there a way to achieve what I want? Maybe a way to make Scroll Lock disable actual text input while it's toggled, but allow hotstrings somehow?

Re: Prevent hotstring from inputting actual text

Posted: 08 Jun 2018, 20:09
by brutus_skywalker
I use hotstrings for various commands as well, the * in the hotstring should autoremove what ever hotstring you used to run the command.

Code: Select all

#If GetKeyState("Scrolllock","T")

:*:ahk::
Run, "C:\Users\Username\AutoHotkey"
Return

Re: Prevent hotstring from inputting actual text

Posted: 15 Jun 2018, 08:31
by Avastgard
As far as I understand, that will simply erase what I typed. While that may work most of the time, sometimes I might have a window open in which the keypresses I send will interfer with the window itself. For example, if I am using Word (which I use most of the day) and have part of a text selected, using the hotstring will delete the selected text and replace it with the hotstring I type, which will later be erased and leave nothing where text used to be.

You could say "well, just unselect the text before sending the hotstring", but that's precisely what I want to avoid. What I want is a way to use the hotstring on the fly, without having to worry about whatever window I have open.

Thanks for the help, though.

Re: Prevent hotstring from inputting actual text

Posted: 15 Jun 2018, 10:49
by brutus_skywalker
I know what you meant,but if you're willing to forgoe hotstrings,long hotkeys by helgef is precisely what you're looking for. Cheers.