How to get the actual hotstring typed with capitalization in AutoHotKey?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jackn11
Posts: 10
Joined: 14 Dec 2020, 17:34

How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by jackn11 » 23 Jan 2021, 20:22

I am using hotstrings in AutoHotKey and want to store the word typed as a string. Is there a way to get the string typed while keeping capitalization data? I tried using A_ThisHotkey, but it does not seem to be case sensitive. Please let me know if you have a solution. Thanks.
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by gregster » 23 Jan 2021, 20:37

Not absolutely sure what you are asking. Can you give an example?

Generally, by default, hotstrings replace case-conform. For example, this hotstring

Code: Select all

::hw::hello world
will return hello world, if I type hw,
will return HELLO WORLD, if I type HW,
and will return Hello world, if I type Hello world.

If this is unwanted, you can add the C1 option.
https://www.autohotkey.com/docs/Hotstrings.htm#Options wrote:C1: Do not conform to typed case. Use this option to make auto-replace hotstrings case insensitive and prevent them from conforming to the case of the characters you actually type. Case-conforming hotstrings (which are the default) produce their replacement text in all caps if you type the abbreviation in all caps. If you type the first letter in caps, the first letter of the replacement will also be capitalized (if it is a letter). If you type the case in any other way, the replacement is sent exactly as defined. When using the #Hotstring directive, C0 can be used to turn this option back off, which makes hotstrings conform again.
Or rather this? The C option:
C: Case sensitive: When you type an abbreviation, it must exactly match the case defined in the script. Use C0 to turn case sensitivity back off.
jackn11
Posts: 10
Joined: 14 Dec 2020, 17:34

Re: How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by jackn11 » 23 Jan 2021, 20:56

Basically, I'm passing the typed string as an argument for a python method to a python program. In order to get the string to send I've tried using A_ThisHotkey, but it does not have the proper capitalization from how I typed the word. For example, ::hw::PythonProgram.hello_world(A_ThisHotkey). That's more pseudo-code than functional code, but it should help you understand what I mean.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by BoBo » 23 Jan 2021, 21:04

Code: Select all

::hw::
	Send % "PythonProgram.hello_world(" . A_ThisHotkey . ")"
	Return

Code: Select all

::hw::
	StringUpper, str, A_ThisHotkey
	Send % "PythonProgram.hello_world(" . str . ")"
	Return
:?:
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by HotKeyIt » 23 Jan 2021, 21:08

Probably:

Code: Select all

Loop {
	Input, v,V,{Space}{Enter},hw`t,btw`t
	If (ErrorLevel="Match")
		MsgBox % v
}
Esc::ExitApp
jackn11
Posts: 10
Joined: 14 Dec 2020, 17:34

Re: How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by jackn11 » 23 Jan 2021, 22:36

@BoBo and @HotKeyIt I really don't understand your code at all please provide an explanation. Also, just to make it even clearer if I have not been clear enough, I will provide another example. If I have a hotstring triggered by "hello world" I want to be able to get and store the string that I actually typed to trigger the hotkey in a variable with the uppercase letters. This way, if I type "hello World" to trigger the hotstring, I would have a string stored in a variable "hello World."
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by HotKeyIt » 24 Jan 2021, 02:31

Run the script and type 'hallo world', then hit Tab key:

Code: Select all

Loop {
	Input, v,V,{Space}{Enter},hallo world`t
	If (ErrorLevel="Match")
		MsgBox % v
}
Esc::ExitApp
Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to get the actual hotstring typed with capitalization in AutoHotKey?

Post by Rohwedder » 24 Jan 2021, 08:14

Hallo,
two case sensitive A_ThisHotkeys, try:

Code: Select all

:cx:hw::ToolTip,% A_ThisHotkey
:CX:HW::ToolTip,% A_ThisHotkey
Post Reply

Return to “Ask for Help (v1)”