How to call a one-line hotstring? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
redrum
Posts: 83
Joined: 25 Jan 2015, 22:57

How to call a one-line hotstring?

08 Jun 2017, 09:53

I have a number of hotkeys and hotstrings that are only enabled (not sure if that is the correct term) if a particular window is active. So these hotkeys and hotstrings are sandwiched between

Code: Select all

#IfWinActive ahk_class [particular app]

#IfWinActive
In this #IfWinActive block, I wish to add a hotkey that itself calls a hotstring within the same block.

The hotstring I want to call is the following text expansion:

Code: Select all

:*:;in::intitle:
The hotkey I tried creating:

Code: Select all

!F6::  
Send, {F6}  
Send, :*:;in
return
The Send function sends the characters :*:;in but this does not execute the text expansion. Where am I going wrong?
User avatar
fischgeek
Posts: 435
Joined: 29 Jan 2014, 21:39

Re: How to call a one-line hotstring?

08 Jun 2017, 10:10

You're confusing the difference between a hotkey and a hotstring. Wouldn't you just want the hotstring to be executed when you type ;in instead of using a hotkey?

Basically, you're asking the Send command to send the following keystrokes: :*:;in when in-fact, all you want is just the hotstring.

Code: Select all

#IfWinActive ahk_class [particular app]
:*:;in::intitle:
#IfWinActive
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: How to call a one-line hotstring?  Topic is solved

08 Jun 2017, 10:44

You can use GoSub to call the hotstring, but only if the hotstring executes another command (Send, Run etc.):

Code: Select all

#IfWinActive ahk_class [particular app]

	:*:;in:: 
		SendInput, intitle:
	return

	!F6::
		Send, {F6}  
		GoSub, :*:;in
	return

#IfWinActive
redrum
Posts: 83
Joined: 25 Jan 2015, 22:57

Re: How to call a one-line hotstring?

08 Jun 2017, 11:52

GEV wrote:You can use GoSub to call the hotstring, but only if the hotstring executes another command (Send, Run etc.):

Code: Select all

#IfWinActive ahk_class [particular app]

	:*:;in:: 
		SendInput, intitle:
	return

	!F6::
		Send, {F6}  
		GoSub, :*:;in
	return

#IfWinActive
Thanks for the explanation and code. Works great!
redrum
Posts: 83
Joined: 25 Jan 2015, 22:57

Re: How to call a one-line hotstring?

08 Jun 2017, 11:55

fischgeek wrote:You're confusing the difference between a hotkey and a hotstring. Wouldn't you just want the hotstring to be executed when you type ;in instead of using a hotkey?

Basically, you're asking the Send command to send the following keystrokes: :*:;in when in-fact, all you want is just the hotstring.

Code: Select all

#IfWinActive ahk_class [particular app]
:*:;in::intitle:
#IfWinActive
No, I want the hotkey because I already have the hotstring, which I sometimes execute directly, but sometimes I want to execute it immediately after pressing F6, so rather than pressing F6 and then type ";in", I want a hotkey that sends F6 and then executes the hotstring.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen and 410 guests