AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Auto-Correct 2 capital letters in a word: WOrd ==> Word
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Thu Mar 01, 2007 12:10 am    Post subject: Reply with quote

Chris wrote:
some people (such as programmers) might find that it interferes with their typing too much. But I'm not really sure how common that is, so comments are welcome.
This script can be made a little more intelligent. E.g. when three capitals are typed in a row, we can keep them unchanged.
Code:
keys = ``1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
Loop Parse, keys
   HotKey ~+%A_LoopField%, Hoty

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,1) "{Right}"
Return
Arbitrary rules can be set, like two shifted keys, followed by a non-alphanumeric character ("US ", "KM.") they can be kept. Here we could really use key history or on_keystroke:. One could also keep his own little (dynamic) dictionary for the words with two neighbor capitals.
Back to top
View user's profile Send private message
sawfoot



Joined: 27 Feb 2007
Posts: 3

PostPosted: Thu Mar 01, 2007 12:14 am    Post subject: sawfoot Reply with quote

All working now, great, thanks. I keep on trying to catch it out but it is always too quick for me.

Using it now the new amendment above makes sense, as you previously would have to use caps lock to type whole caps words, as holding shift wouldn't work it, so it makes it more usable. The non-alphanumeric character suggestion sounds good - preferable to a list of exclusions.
You can type things like US if you pause slightly currently - so I would recommend changing the 999ms to a lower figure - maybe around 300 from my testing.

You could always keep the improved version in, and comment it out with a note, or leave it in and allow people to comment out/delete if they wish - this would seem to be a good idea as casual users wouldn't be aware of its existence unless they delve into these forums.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Mar 01, 2007 2:04 am    Post subject: Reply with quote

I've added this to the script, but omitted autocorrection for digits and punctuation because I suspect they might do more harm than good (not sure). Also, I've made this section disabled by default because it sometimes causes unwanted corrections such as IfEqual->Ifequal. (I think a lot of people use this script, so I'm trying to avoid addihng features unless they're reasonably certain to do more good than harm for the general public.)

I also changed the style of the code to be more conventional, namely to avoid IfEqual and implicit concatenation:
Code:
;-------------------------------------------------------------------------------
; The following section auto-corrects two consecutive capital letters in a word.
; For example, "WOrd" becomes "Word".  It is disabled by default since it might
; cause unwanted corrections such as IfEqual->Ifequal.  To enable it, remove
; the /*..*/ symbols from around it.
; This section is from Laszlo's script at http://www.autohotkey.com/forum/topic9689.html
;-------------------------------------------------------------------------------
/*
; The first line of code below is the set of letters, digits, and/or symbols
; that are eligible for this type of correction.  Customize if you wish:
keys = abcdefghijklmnopqrstuvwxyz
Loop Parse, keys
   HotKey ~+%A_LoopField%, Hoty

Hoty:
   CapCount := SubStr(A_PriorHotKey,2,1)="+" && A_TimeSincePriorHotkey<999 ? CapCount+1 : 1
   if CapCount = 2
      SendInput % "{BS}" . SubStr(A_ThisHotKey,3,1)
   else if CapCount = 3
      SendInput % "{Left}{BS}+" . SubStr(A_PriorHotKey,3,1) . "{Right}"
Return
*/


Refinements are welcome. Thanks for the script.
Back to top
View user's profile Send private message Send e-mail
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Thu Mar 01, 2007 2:58 am    Post subject: Reply with quote

Handling some CamelCase words (like IfEqual) can be easily accomplished with a dummy hotkey, like
Code:
~Shift Up::Return
It will change A_PriorHotKey, so the counting restarts at the next capital letter.

It is a good idea to exclude certain shifted keys, which are often duplicated: ##, &&, **, __, ++, ||, <<, >>. Others could remain.

In case of Ms Word, excluding ~, # looks necessary. For some unknown reasons, sometimes, after a space, they result in some extra or unexplained characters in the text. I did not experience this in other applications.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Thu Mar 01, 2007 3:58 am    Post subject: Reply with quote

If you want to leave two capitals alone if they are followed by an un-shifted punctuation mark, try adding the following hotkeys to the script.
Code:
~Shift Up::      ; handle CamelCase
   key0 := SubStr(A_PriorHotKey,2,1)="+" && A_TimeSincePriorHotkey<999 && CapCount=2
           ? SubStr(A_PriorHotKey,3,1) : ""
Return

~.::
~,::
~'::
~"::
~-::
   If (key0 <> "" && A_PriorHotKey = "~Shift Up" && A_TimeSincePriorHotkey<999)
      SendInput % "{Left}{BS}+" key0 "{Right}"
Return
At Shift Up we check if the previous key was changed to lower case, within the last second. If yes, we save the changed key in the variable key0. The handled punctuation marks always come after a Shift Up. If not more than one second passed, we can correct key0 back to capital.

Of course, such simple scripts cannot be foolproof. If you move the insertion point or the active window changes within the critical second, the correction appears at the wrong place. We ought to know it, or if other keys were pressed. With proper key history we could remove the timing restrictions.
Back to top
View user's profile Send private message
sunil kanta swain
Guest





PostPosted: Fri May 02, 2008 9:31 am    Post subject: sub:how to permanently delete autocorrect from the ms word Reply with quote

Hello,

i searched for permanently delete autocorrect from ms word.could u kindly to help me out for this kind of problem ?

Regards
sunil kanta swain,
system administration,
C Bay Systems (India) Pvt ltd,
Bangalore 560008
mail ID:sunilkanta033@gmail.com /sunil_swain37@yahoo.co.in
Back to top
sunil kanta swain
Guest





PostPosted: Fri May 02, 2008 9:33 am    Post subject: Re: sub:how to permanently delete autocorrect from the ms wo Reply with quote

sunil kanta swain wrote:
Hello,

i searched for permanently delete autocorrect from ms word.could u kindly to help me out for this kind of problem ?mail methe solution asap.

Regards
sunil kanta swain,
system administration,
C Bay Systems (India) Pvt ltd,
Bangalore 560008
mail ID:sunilkanta033@gmail.com /sunil_swain37@yahoo.co.in
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group