Prevent hotstring from inputting actual text

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Avastgard
Posts: 133
Joined: 30 Sep 2016, 21:54

Prevent hotstring from inputting actual text

08 Jun 2018, 13:08

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?
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Prevent hotstring from inputting actual text

08 Jun 2018, 20:09

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
Outsourcing Clicks & Presses Since 2004.
Avastgard
Posts: 133
Joined: 30 Sep 2016, 21:54

Re: Prevent hotstring from inputting actual text

15 Jun 2018, 08:31

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.
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Prevent hotstring from inputting actual text

15 Jun 2018, 10:49

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.
Outsourcing Clicks & Presses Since 2004.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, mikeyww, scriptor2016 and 262 guests