Toggle Auto-Correct Two Consecutive Capitals

Get help with using AutoHotkey and its commands and hotkeys
Whazzzzzup15
Posts: 41
Joined: 13 Apr 2019, 16:12

Toggle Auto-Correct Two Consecutive Capitals

17 Nov 2020, 15:00

I have been utilizing the TWo Consecutive word script and it works perfect, but on some programs such as Excel, it doesn't output as wanted due to working within a cell.

Is there anyway to toggle this script on and off with with a key such as F12 so I can work normally within certain programs?

Code: Select all

keys = ``qwertyuiopasdfghjklzxcvbnm.
; keys = ``1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
Loop Parse, keys
   HotKey ~+%A_LoopField%, Hoty        ; Shifted keys to monitor

keys = 1234567890qwertyuiopasdfghjklzxcvbnm
Loop Parse, keys
   HotKey ~%A_LoopField%, Normal       ; Unshifted keys to register as hotkeys

keys = ``-=[]\;',./ ;[email protected]#$^&*)_+:
Loop Parse, keys
   HotKey ~%A_LoopField%, ~Space       ; Special chars to keep 2 capitals before

Hoty:
   CapCount := SubStr(A_PriorHotKey,2,1)="+" && A_TimeSincePriorHotkey<999 ? CapCount+1 : 1
   IfEqual CapCount,2, SendInput % "{BS}{"  SubStr(A_ThisHotKey,3,1) "}"
   IfEqual CapCount,3, SendInput % "{Left}{BS}+{" SubStr(A_PriorHotKey,3) "}{Right}"
Normal:
Return
User avatar
boiler
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Toggle Auto-Correct Two Consecutive Capitals

17 Nov 2020, 15:10

This should be better than having to toggle it on and off. Try putting the line below at the top of your script. All subsequent hotkeys created by the Hotkey command will be subject to it.

Code: Select all

HotKey, IfWinNotActive, ahk_exe EXCEL.EXE
Whazzzzzup15
Posts: 41
Joined: 13 Apr 2019, 16:12

Re: Toggle Auto-Correct Two Consecutive Capitals

17 Nov 2020, 19:55

Yeah, I had this, but I have the same issue with other programs. Anyway to toggle too?
User avatar
boiler
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Toggle Auto-Correct Two Consecutive Capitals

17 Nov 2020, 20:05

You can use a combination of an #If and a Hotkey, If, Expression command where the expression would be a toggle variable (and probably a !WinActive(...)). It gets complicated since the latter requires the former, and you want to have it both as a toggle and as an IfWinNotActive. You can try using those things, but I think you have to be pretty careful how you structure it to get it all working the way you want.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], HiSoKa, songdg, TAC109 and 27 guests