AutoHotkey Community

It is currently May 26th, 2012, 5:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: March 1st, 2007, 12:10 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: sawfoot
PostPosted: March 1st, 2007, 12:14 am 
Offline

Joined: February 27th, 2007, 7:00 pm
Posts: 3
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2007, 2:04 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2007, 2:58 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2007, 3:58 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 2nd, 2008, 9:31 am 
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


Report this post
Top
  
Reply with quote  
PostPosted: May 2nd, 2008, 9:33 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2009, 12:32 am 
Offline

Joined: February 23rd, 2009, 12:29 am
Posts: 2
Laszlo,

I have found that this script also applies to two letter acronyms which should occasionally remain capitalized such as AM, PM, TV, etc. I know it would break the script from correcting such errors as "MY book" but I think I would prefer that. Is there a check that I could add to the script for two letter strings that leaves both letters capitalized?

Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2009, 1:33 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Add ~Space to the hotkeys monitoring 2 capitals:
Code:
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 = ``-=[]\;',./
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

~Shift Up::                            ; Handle CamelCase
   key0 := SubStr(A_PriorHotKey,2,1)="+" && A_TimeSincePriorHotkey<999 && CapCount=2
           ? SubStr(A_PriorHotKey,3) : ""
Return

~Space::                               ; Restore 2 capitals before special chars
   If (key0 <> "" && A_PriorHotKey = "~Shift Up" && A_TimeSincePriorHotkey<999)
      SendInput % "{Left}{BS}+{" key0 "}{Right}"
Return
Now, if you type "AM"{Space} the M remains capitalized. Similar to "AM."

Edit 20090223: Bugfix, regular keys restart counting


Last edited by Laszlo on February 23rd, 2009, 7:25 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2009, 2:00 am 
Offline

Joined: February 23rd, 2009, 12:29 am
Posts: 2
Hi Laszlo,

Thanks for the quick response! Much appreciated. There appears to be a problem with the new script though. When compiling the script I receive the following error message:

Note: The hotkey H~.:: will not be active because it does not exist in the current keyboard layout.

Also, and maybe this is related to the above error, if I type DId [space] it changes to DiI.

Again, thanks so much for helping me out with this. If you might be able to take another look at the script when you have a minute I would really appreciate it. Thanks!!! :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2009, 7:30 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I don't get compile errors. Maybe there was a copy-paste problem?

But, you are right. There was a bug in the script. I corrected it in my previous post. I don't have time to test it, so please report further bugs.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2009, 7:36 am 
Lazlo I tried this and it worked well. Now I tried to integrate it to my ahk and now it doesn't work. Help.

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

Hoty:
   StringMid c0, A_PriorHotKey,2, 1
   StringMid c1, A_ThisHotKey, 3, 1
   If (c0 = "+" and A_TimeSincePriorHotkey < 999)
      Send {BS}%c1%
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2009, 7:39 am 
I tried putting it on top, right below the password, in the middle and in the end, all the same doesn't work. Help me understand how this works.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2009, 3:28 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
The first 3 lines belong to the auto-execute section of the script (top), the Hoty subroutine has to be in the end.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2009, 1:30 am 
Thanks Lazlo for the quick response. Works perfect now. :P


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Miguel, SifJar, SKAN and 53 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group