AutoHotkey Community

It is currently May 24th, 2012, 7:06 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 35 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: May 7th, 2006, 9:09 pm 
Hello,

i searched the forum up and down..

I would need a script which automatically corrects all words contanining
2 capitals at the beginning, e.g.

WOrd ==> Word
HOuse => House
MAnual ==> Manual
...

Is this possible? It should work in realtime... ;-)

Regards
Markus


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2006, 9:38 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2537
It is possible (anything is possible ;) ). You will first need to separate the words. One method might be to use Loop, Parse. This will allow you to process one word at a time. Next you would need to test the second character of each word to check to see if it is Upper or Lower case (have a look at the various String functions available). One method for testing the second character could be to look up the Ascii value (Asc())of the character. If you look at an Ascii table you'll find that the upper and lower case letters are grouped together. This means that (following the table in the link) upper case letters would return a value between 65 and 90. To change the character to lower case you could use a built in function (StringLower / StringUpper)or add 32 to get the lower case equivalent.

Quote:
It should work in realtime... ;-)

Could you give a bit more detail on this please? As you type? (a friend with a ruler could solve this problem a bit quicker for you if it's a bad habit ;) :twisted: ). Is the text being entered in a AutoHotkey window? (in an edit control maybe?) or in a different application?


Last edited by corrupt on May 7th, 2006, 9:41 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2006, 9:38 pm 
Skrommel's CAPshift arbeitet in Realtime. Kaum Text selected schon konvertiert! Link bereits im Deutschen Forum geposted.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2006, 9:53 pm 
Hello corrupt,

here's an example:

MY name is MArkus.
..^...............^

Here you see i hold down the shift key a little bit too long, so te script should autocorrect the "MY" to "My" after pressing the space bar and should auto correct the "MArkus" to "Markus" after pressing "."

That's what I need... but I'm no scripter at all...sorry

Regards
Markus


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2006, 10:00 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2537
I don't mind trying to put something together to help get you started :) . It would help to know where the text is being entered though. A script can be written a few different ways to detect the keys that were typed but it makes a difference where they are typed to be able to correct the keystrokes after.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2006, 10:52 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
Here is a case correction function:
Code:
CaseCorrect(str) {
   Loop, Parse, str, %A_Space%
      Loop, Parse, A_LoopField
         If (A_Index = 2) {
            StringLower, n, A_LoopField
            StringReplace, str, str, %x%%A_LoopField%, %x%%n%
         } Else x := A_LoopField
   Return, str
}


Example: MsgBox, % CaseCorrect("WOrd, HOuse, MAnual...")

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2006, 11:48 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
This script corrects double shifted characters as you type. All shifted keys on the keyboard are defined as hotkeys, which do not do anything, except if the previous hotkey was also a shifted key and less than 1 second passed. In this case the last character is removed and replaced with the un-shifted key.

It assumes, you don't have other hotkeys defined, which have + as the second character. Add your other hotkey or hotstring definitions before the Hoty label.
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
You have to change the variable "keys" for non-US keyboards.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2006, 2:42 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
:shock: That's amazingly compact!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2006, 5:16 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Dear Laszlo, :)

Thats brilliant! :D

Thanks for posting.. It is very helpful to me. :D

Regards, :)

PS: Script Showcase?

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2006, 9:49 pm 
Dear Laszlo!

Thats really brilliant! I was looking for a solution a long time!

The script is short, very fast - perfect!

Thank you very much!

Best Regards
Markus


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2007, 7:34 pm 
Offline

Joined: February 27th, 2007, 7:00 pm
Posts: 3
I couldn't get this to work - I have a non us keyboard, but don't get what changes do I make to the keys variable?
Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2007, 5:20 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
You should list the characters written on the keyboard keys, to be shown when the shift key is not pressed. Hopefully, the Windows local settings are honored by AHK.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2007, 2:51 pm 
Offline

Joined: February 27th, 2007, 7:00 pm
Posts: 3
ok, thanks. I changed them, as there were slightly difference for a UK keyboard, but the function still doesn't work. PErhaps I will just have to live without it, unless you have any other ideas...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2007, 3:45 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
What does not work? Try holding down the shift key and press another key twice, quickly, like P. What do you get in an editor, like Notepad? You should see "Pp".
You could try SendPlay or SendInput, as below.
Code:
keys = ``1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
Loop Parse, keys
   HotKey ~+%A_LoopField%, Hoty

Hoty:
   If (SubStr(A_PriorHotKey,2,1) = "+" and A_TimeSincePriorHotkey < 999)
      SendInput % "{BS}{RAW}" SubStr(A_ThisHotKey,3,1)
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2007, 11:26 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Sawfoot e-mailed me his AutoCorrect script and I noticed that this topic's code wasn't in the auto-execute section. I've notified him of this.

By the way, Sawfoot sent me 900 additional misspellings, mostly based on MS Word's AutoCorrect. The topic he used to get them is jaco0646's at http://www.autohotkey.com/forum/viewtopic.php?t=8057

I've included these new misspellings in the main AutoCorrect script at http://www.autohotkey.com/download/wiki ... orrect.ahk

However, I didn't include the double-cap correction from this topic here because 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.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, ELengefeld, janopn, KenC, Kirtman, Klark92, Ohnitiel, Pulover, quintijn, rbrtryn and 64 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