Automation

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Post AHK
Posts: 3
Joined: 03 Aug 2021, 21:03

Automation

Post by Post AHK » 03 Aug 2021, 21:23

Hi. I am new to this forum. My query is I want to autocorrect 1T as 1000 and 10T as 10000 and so on. Here T will be 1000 and it will multiply the number before it and autocorrect the word. How can I achieve this through an ahk file.
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Automation

Post by boiler » 03 Aug 2021, 22:27

The easiest way is to make a number of auto-replace hotstrings:

Code: Select all

::1T::1000
::10T::10000
::100T::100000

It could be made to more generically replace the T with 000, but that would be more involved and not worth the effort and extra code if you have a relatively small number of cases. Would you really have more than 100T before you went with something like 1M, 10M, 100M? Or will you be using T with more than just multiples of 10, like 34T?
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Automation

Post by mikeyww » 03 Aug 2021, 22:31

Code: Select all

#If !on
~1::
~2::
~3::
~4::
~5::
~6::
~7::
~8::
~9::
~0::
on := True
Input, str, V, -()[]{}:;'"/\`,.?!`n `tt
t := ErrorLevel = "EndKey:T"
Send % RegExMatch(str, "^\d*$") && t ? "{BS}000" : ""
on := False
Return
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Automation

Post by boiler » 03 Aug 2021, 22:33

Now mikeyww showed it's worth the effort to make it work for the generic case. :D
teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Automation

Post by teadrinker » 04 Aug 2021, 13:24

Code: Select all

str := "1"
Loop 10
   HotString( ":*:" . (str .= A_Index = 1 ? "" : "0") . "T", str*1000 )
Return
Post AHK
Posts: 3
Joined: 03 Aug 2021, 21:03

Re: Automation

Post by Post AHK » 11 Aug 2021, 11:50

@mikeyww
Sir, the code is working but with Keypad numbers only, not with the numpad keys.

The below mentioned 2 scripts working when they run individually but not in combination, how can I add these two scripts in one.
1.

Code: Select all

#If !on
~1::
~2::
~3::
~4::
~5::
~6::
~7::
~8::
~9::
~0::
on := True
Input, str, V, -()[]{}:;'"/\`,.?!`n `tt
t := ErrorLevel = "EndKey:T"
Send % RegExMatch(str, "^\d*$") && t ? "{BS}000" : ""
on := False
Return
2.

Code: Select all

#If !on
~1::
~2::
~3::
~4::
~5::
~6::
~7::
~8::
~9::
~0::
on := True
Input, str, V, -()[]{}:;'"/\`,.?!`n `ll
l := ErrorLevel = "EndKey:L"
Send % RegExMatch(str, "^\d*$") && l ? "{BS}00000" : ""
on := False
Return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Automation

Post by mikeyww » 11 Aug 2021, 12:31

Ideas to get you started:

Code: Select all

#If !on
~Numpad1::
~Numpad2::
on := True
Input, str, V, -()[]{}:;'"/\`,.?!`n `ttl
t := ErrorLevel = "EndKey:T", l := ErrorLevel = "EndKey:L", n := RegExMatch(str, "^\d*$")
Send % n && t ? "{BS}000" : n && l ? "{BS}00000" : ""
on := False
Return
Post AHK
Posts: 3
Joined: 03 Aug 2021, 21:03

Re: Automation

Post by Post AHK » 14 Aug 2021, 07:34

This is the code I want.
@mikeyww
Thanks a lot, sir.
Post Reply

Return to “Ask for Help (v1)”