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 

Trying to Create Shift-F3 Case Changer Like Word

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Thu Mar 18, 2010 10:44 pm    Post subject: Trying to Create Shift-F3 Case Changer Like Word Reply with quote

Hi, I'm trying to make a looping case changer like the one in MS Word. There if you hold down the Shift key and tap on the F3 key, it will cycle through setting the selection to lower case, upper case and Title case and then back to lower case on the fourth tap of F3.

I have succeeded in doing simple modifications and synthesizing of skrommel's excellent CAPShift, HotKeyIt's RapidHotkey and Laszo's Morse Key, both also excellent.

I have two problems now:

1. Unlike MS Word, the case doesn't change until I lift the shift key. In Word every time you tap the F3 key and change happens right away. I have tried a bunch of things to fix this without success.

2. I was able to move the text insertion point/caret back to the start, selecting along the way by sending the shift key, however, if I'm changing the case of a whole paragraph, the caret takes some time to get back to the start. It would nice if it just jumped and still kept the paragraph selected.

Thanks in advance for the help.

Below is the code:
Code:

Shift & F3::RapidHotkey("LOWER""UPPER""TITLE""INVERT",1,0.2,1)

LOWER:
Gosub,CUT
StringLower,string,string
Gosub,PASTE
Return

UPPER:
Gosub,CUT
StringUpper,string,string
Gosub,PASTE
Return

TITLE:
Gosub,CUT
StringLower,string,string,T
Gosub,PASTE
Return

INVERT:
AutoTrim,Off
StringCaseSense,On
Gosub,CUT
lower=abcdefghijklmnopqrstuvwxyzĉĝċ
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZĈĜĊ
StringLen,length,string

Loop,%length%
{
  StringLeft,char,string,1
  StringGetPos,pos,lower,%char%
  pos+=1
  If pos<>0
    StringMid,char,upper,%pos%,1
  Else
  {   
    StringGetPos,pos,upper,%char%
    pos+=1
    If pos<>0
      StringMid,char,lower,%pos%,1
  }
  StringTrimLeft,string,string,1
  string=%string%%char%
}
Gosub,PASTE
Return

CUT:
   Send,^x
   ClipWait,1
   string=%clipboard%
   Return

PASTE:
   clipboard=%string%
   Send,^v
   StringLen,length,clipboard
   Send,{Shift Down}
   Send,{Left %length%}
   Send,{Shift Up}
   Return
   
;#####################################
;RapidHotkey() and Morse() functions #
;#####################################
RapidHotkey(keystroke, times="1", delay=0, IsLabel=1)
{
   Pattern := Morse(delay*1000)
   If (StrLen(Pattern) < 2 and Chr(Asc(times)) != "1")
      Return
   If (times = "" and InStr(keystroke, """"))
   {
      Loop, Parse, keystroke,""   
         If (StrLen(Pattern) = A_Index+1)
            continue := A_Index, times := StrLen(Pattern)
   }
   Else if (RegExMatch(times, "^\d+$") and InStr(keystroke, """"))
   {
      Loop, Parse, keystroke,""
         If (StrLen(Pattern) = A_Index+times-1)
            times := StrLen(Pattern), continue := A_Index
   }
   Else if InStr(times, """")
   {
      Loop, Parse, times,""
         If (StrLen(Pattern) = A_LoopField)
            continue := A_Index, times := A_LoopField
   }
   Else if (times = "")
      continue = 1, times = 2
   Else if (times = StrLen(Pattern))
      continue = 1
   If !continue
      Return
   Loop, Parse, keystroke,""
      If (continue = A_Index)
         keystr := A_LoopField
   Loop, Parse, IsLabel,""
      If (continue = A_Index)
         IsLabel := A_LoopField
   hotkey := RegExReplace(A_ThisHotkey, "[\*\~\$\#\+\!\^]")
   IfInString, hotkey, %A_Space%
      StringTrimLeft, hotkey,hotkey,% InStr(hotkey,A_Space,1,0)
   Loop % times
      backspace .= "{Backspace}"
   keywait = Ctrl|Alt|Shift|LWin|RWin
   Loop, Parse, keywait, |
      KeyWait, %A_LoopField%
   If ((!IsLabel or (IsLabel and IsLabel(keystr))) and InStr(A_ThisHotkey, "~") and !RegExMatch(A_ThisHotkey
   , "i)\^[^\!\d]|![^\d]|#|Control|Ctrl|LCtrl|RCtrl|Shift|RShift|LShift|RWin|LWin|Escape|BackSpace|F\d\d?|"
   . "Insert|Esc|Escape|BS|Delete|Home|End|PgDn|PgUp|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|AppsKey|"
   . "PrintScreen|CtrlDown|Pause|Break|Help|Sleep|Browser_Back|Browser_Forward|Browser_Refresh|Browser_Stop|"
   . "Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|MButton|RButton|LButton|"
   . "Media_Next|Media_Prev|Media_Stop|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2"))
      Send % backspace
   If (WinExist("AHK_class #32768") and hotkey = "RButton")
      WinClose, AHK_class #32768
   If !IsLabel
      Send % keystr
   else if IsLabel(keystr)
      Gosub, %keystr%
   Return
}   
Morse(timeout = 400) { ;by Laszo -> http://www.autohotkey.com/forum/viewtopic.php?t=16951 (Modified to return: KeyWait %key%, T%tout%)
   tout := timeout/1000
   key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
   IfInString, key, %A_Space%
   StringTrimLeft, key, key,% InStr(key,A_Space,1,0)
   Loop {
      t := A_TickCount
      KeyWait %key%, T%tout%
     Pattern .= A_TickCount-t > timeout
     If(ErrorLevel)
      Return Pattern
     KeyWait %key%,DT%tout%
      If (ErrorLevel)
         Return Pattern
   }
}
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Fri Mar 19, 2010 12:49 am    Post subject: Reply with quote

try this code,
sorry it moves the mouse but doesn't put it back where it was Embarassed
Code:
#Persistent
return

f12::reload

f1::
SetTimer, WatchCaret, 100
return
WatchCaret:
ToolTip, X%A_CaretX% Y%A_CaretY%, A_CaretX, A_CaretY - 20
return



Shift & F3::RapidHotkey("LOWER""UPPER""TITLE""INVERT",1,0.2,1)

where_was_caret:
msgbox start %startx% %starty% `nend %endx% %endy%`nafterpaste %afterpastex% %afterpastey%
return

LOWER:
Gosub,CUT
StringLower,string,string
Gosub,PASTE
;gosub where_was_caret
Return

UPPER:
Gosub,CUT
StringUpper,string,string
Gosub,PASTE
Return

TITLE:
Gosub,CUT
StringLower,string,string,T
Gosub,PASTE
Return

INVERT:
AutoTrim,Off
StringCaseSense,On
Gosub,CUT
lower=abcdefghijklmnopqrstuvwxyzĉĝċ
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZĈĜĊ
StringLen,length,string

Loop,%length%
{
  StringLeft,char,string,1
  StringGetPos,pos,lower,%char%
  pos+=1
  If pos<>0
    StringMid,char,upper,%pos%,1
  Else
  {   
    StringGetPos,pos,upper,%char%
    pos+=1
    If pos<>0
      StringMid,char,lower,%pos%,1
  }
  StringTrimLeft,string,string,1
  string=%string%%char%
}
Gosub,PASTE
Return

CUT:

   endx:=A_CaretX
   endy:=A_CaretY

   Send,^x
   ClipWait,1
   string=%clipboard%

;sleep, 2000
   startx:=A_CaretX
   starty:=A_CaretY

   Return

PASTE:
   clipboard=%string%
   Send,^v
   StringLen,length,clipboard
   Send,{Shift Down}
;sleep ,1000
   afterpastex:=A_CaretX
   afterpastey:=A_CaretY
;sleep, 1000
    mousemove, %startx%, %starty%, 10
    click

;temp:=A_KeyDelay
;SetKeyDelay , -1

;sleep ,1000
;   Send,{Left %length%}

;SetKeyDelay , %temp%

   Send,{Shift Up}
   Return
   
;#####################################
;RapidHotkey() and Morse() functions #
;#####################################
RapidHotkey(keystroke, times="1", delay=0, IsLabel=1)
{
   Pattern := Morse(delay*1000)
   If (StrLen(Pattern) < 2 and Chr(Asc(times)) != "1")
      Return
   If (times = "" and InStr(keystroke, """"))
   {
      Loop, Parse, keystroke,""   
         If (StrLen(Pattern) = A_Index+1)
            continue := A_Index, times := StrLen(Pattern)
   }
   Else if (RegExMatch(times, "^\d+$") and InStr(keystroke, """"))
   {
      Loop, Parse, keystroke,""
         If (StrLen(Pattern) = A_Index+times-1)
            times := StrLen(Pattern), continue := A_Index
   }
   Else if InStr(times, """")
   {
      Loop, Parse, times,""
         If (StrLen(Pattern) = A_LoopField)
            continue := A_Index, times := A_LoopField
   }
   Else if (times = "")
      continue = 1, times = 2
   Else if (times = StrLen(Pattern))
      continue = 1
   If !continue
      Return
   Loop, Parse, keystroke,""
      If (continue = A_Index)
         keystr := A_LoopField
   Loop, Parse, IsLabel,""
      If (continue = A_Index)
         IsLabel := A_LoopField
   hotkey := RegExReplace(A_ThisHotkey, "[\*\~\$\#\+\!\^]")
   IfInString, hotkey, %A_Space%
      StringTrimLeft, hotkey,hotkey,% InStr(hotkey,A_Space,1,0)
   Loop % times
      backspace .= "{Backspace}"
   keywait = Ctrl|Alt|Shift|LWin|RWin
   Loop, Parse, keywait, |
      KeyWait, %A_LoopField%
   If ((!IsLabel or (IsLabel and IsLabel(keystr))) and InStr(A_ThisHotkey, "~") and !RegExMatch(A_ThisHotkey
   , "i)\^[^\!\d]|![^\d]|#|Control|Ctrl|LCtrl|RCtrl|Shift|RShift|LShift|RWin|LWin|Escape|BackSpace|F\d\d?|"
   . "Insert|Esc|Escape|BS|Delete|Home|End|PgDn|PgUp|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|AppsKey|"
   . "PrintScreen|CtrlDown|Pause|Break|Help|Sleep|Browser_Back|Browser_Forward|Browser_Refresh|Browser_Stop|"
   . "Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|MButton|RButton|LButton|"
   . "Media_Next|Media_Prev|Media_Stop|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2"))
      Send % backspace
   If (WinExist("AHK_class #32768") and hotkey = "RButton")
      WinClose, AHK_class #32768
   If !IsLabel
      Send % keystr
   else if IsLabel(keystr)
      Gosub, %keystr%
   Return
}   
Morse(timeout = 400) { ;by Laszo -> http://www.autohotkey.com/forum/viewtopic.php?t=16951 (Modified to return: KeyWait %key%, T%tout%)
   tout := timeout/1000
   key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
   IfInString, key, %A_Space%
   StringTrimLeft, key, key,% InStr(key,A_Space,1,0)
   Loop {
      t := A_TickCount
      KeyWait %key%, T%tout%
     Pattern .= A_TickCount-t > timeout
     If(ErrorLevel)
      Return Pattern
     KeyWait %key%,DT%tout%
      If (ErrorLevel)
         Return Pattern
   }
}
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Fri Mar 19, 2010 4:37 am    Post subject: Thanks for getting me experimenting Reply with quote

This seems acceptable for now:
Code:

PASTE:
   clipboard=%string%
   Send,^v
   StringLen,length,clipboard
    SetKeyDelay, -1
   Send,{Shift Down}
   Send,{Left %length%}
   Send,{Shift Up}
   Return


I tried fooling around with getting the carets X and Y position via A_CaretX and A_CaretY. Apparently these functions don't work reliably in many programs like Adobe Reader and Firefox.

I even saw someone suggest using PixelGetColor to find the color of the selection/highlighting from just to the left of the caret (or something similar) and then finding the first instance of this color at the beginning of the selection. So I moved the mouse around with the left button clicked down between the coordinate for the first discovered pixel with the color and the A_CaretX and A_CaretY. The latter sort of worked too, but left some sections of the original text unhighlighted.

My code above is not instantaneous but it may be good enough for now...unless someone has a better suggestion. Thanks again for giving me the spirit to try some more stuff Very Happy.


Last edited by socrtwo on Fri Mar 19, 2010 4:41 am; edited 1 time in total
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Fri Mar 19, 2010 4:40 am    Post subject: So #2. Is OK Now - Still need Suggestions for No. 1 Reply with quote

So #2 is fine for now, but #1 still needs taking care of Very Happy, if anyone is in the suggestion spirit.
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Fri Mar 19, 2010 4:37 pm    Post subject: There is a Problem With Issue #2 Still Reply with quote

It turns out there is an issue with topic #2. In this code:
Code:

PASTE:
   clipboard=%string%
   Send,^v
   StringLen,length,clipboard
    SetKeyDelay, -1
   Send,{Shift Down}
   Send,{Left %length%}
   Send,{Shift Up}
   Return

StringLen is counting the line returns as characters in for instance Notepad. Thus the
Code:
Send,{Left %length%}

line sends too many left arrow caret movements and the selection overshoots the initial selection adding to it as many characters as there are lines in the selection...

Any suggestions how to stop this??
Back to top
View user's profile Send private message
None



Joined: 28 Nov 2009
Posts: 3086

PostPosted: Fri Mar 19, 2010 7:34 pm    Post subject: Reply with quote

I was messing with it just including the built in ones and came up with this
Code:
State=0
*F3::
If !GetKeyState("Shift","P")
  Return
Send ^x
StringReplace, Length, Clipboard, `r`n , `n, All ;Replace `r`n with single char before counting
Len:=strlen(Length)
If State=0
 Stringlower, Changed, Clipboard
If State=1
 Stringupper, Changed, Clipboard
If State=2
 Stringlower, Changed, Clipboard ,T
State:=State<2 ? State+1 : 0
Clipboard:=Changed
Send ^v
Sleep 50
SendInput {Blind}{Left %Len%}
Return
You could easily add more states for sentence case and inverse case (but invert of what original? Title?)

Last edited by None on Fri Mar 19, 2010 9:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Fri Mar 19, 2010 8:31 pm    Post subject: Re: Thanks for getting me experimenting Reply with quote

socrtwo wrote:
I tried fooling around with getting the carets X and Y position via A_CaretX and A_CaretY. Apparently these functions don't work reliably in many programs like Adobe Reader and Firefox.


You show me where your paste routine works in Adobe Reader Arrow and I'll eat my hat Cool
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Fri Mar 19, 2010 8:44 pm    Post subject: Sorry Adobe Writer Reply with quote

Brain Freeze Embarassed
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Fri Mar 19, 2010 10:25 pm    Post subject: Excellent! Reply with quote

None wrote:
I was messing with it just including the built in ones and came up with this
Code:
State=0
*F3::
If !GetKeyState("Shift","P")
  Return
Send ^x
StringReplace, Length, Clipboard, `r`n , `n, All
Len:=strlen(Length)
If State=0
 Stringlower, Changed, Clipboard
If State=1
 Stringupper, Changed, Clipboard
If State=2
 Stringlower, Changed, Clipboard ,T
State:=State<2 ? State+1 : 0
Clipboard:=Changed
Send ^v
Sleep 50
SendInput {Blind}{Left %Len%}
Return


Excellent! Very Happy . This is going to take some time to see how you did it.

Anyway it works outstandingly. Maybe it's too much to ask but can we extend Shift-F3 to Sentence and Invert case too. I'll see what headway I can make on those. There is some code from Invert Case Code from my original, but I haven't seem to get it to work with the above yet.
Back to top
View user's profile Send private message
None



Joined: 28 Nov 2009
Posts: 3086

PostPosted: Sat Mar 20, 2010 1:38 am    Post subject: Reply with quote

I altered the Invert code you had above to make it a function
Code:
Invert(String) {
AutoTrim,Off
StringCaseSense,On
lower=abcdefghijklmnopqrstuvwxyzĉĝċ
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZĈĜĊ
StringLen,INVlength,string

Loop,%INVlength%
{
  StringLeft,char,string,1
  StringGetPos,pos,lower,%char%
  pos+=1
  If pos<>0
    StringMid,char,upper,%pos%,1
  Else
  {   
    StringGetPos,pos,upper,%char%
    pos+=1
    If pos<>0
      StringMid,char,lower,%pos%,1
  }
  StringTrimLeft,string,string,1
  string=%string%%char%
}
Return %string%
}
so you could use it like
Code:
State=0
*F3::
If !GetKeyState("Shift","P")
  Return
Send ^x
StringReplace, Length, Clipboard, `r`n , `n, All
Len:=strlen(Length)
If State=0
 Changed:=Invert(Clipboard) ;call the INVERT function
If State=1
 Stringlower, Changed, Clipboard
If State=2
 Stringupper, Changed, Clipboard
If State=3
 Stringlower, Changed, Clipboard ,T
State:=State<3 ? State+1 : 0
Clipboard:=Changed
Send ^v
Sleep 50
SendInput {Blind}{Left %Len%}
Return
you can put the function at the end of the script a Standard Lib folder or include it from anywhere you want Smile

Also Laszlo made some Sentence Case code that could also be turned into a function and used the same way. If you need help with that just ask Smile
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Sat Mar 20, 2010 3:20 am    Post subject: Excellent Reply with quote

Excellent, thanks so much. I'll try out yours and Laszlo's functions. This is super.
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Sat Mar 20, 2010 7:08 pm    Post subject: Took Your Suggestion Reply with quote

I took the suggestion. Here's the result:
Code:

State=0
*F3::
If !GetKeyState("Shift","P")
  Return
Send ^x
StringReplace, Length, Clipboard, `r`n , `n, All
Len:=strlen(Length)
If State=0
 Changed:=Invert(Clipboard) ;call the Invert function
If State=1
 Stringlower, Changed, Clipboard
If State=2
 Stringupper, Changed, Clipboard
If State=3
 Stringlower, Changed, Clipboard ,T
If State=4
 Changed:=Title(Clipboard) ;call the Title function
State:=State<4 ? State+1 : 0
Clipboard:=Changed
Send ^v
Sleep 50
SendInput {Blind}{Left %Len%}
Return

INVERT(String){
AutoTrim,Off
StringCaseSense,On
lower=abcdefghijklmnopqrstuvwxyzĉĝċ
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZĈĜĊ
StringLen,INVlength,String

Loop,%INVlength%
{
  StringLeft,char,string,1
  StringGetPos,pos,lower,%char%
  pos+=1
  If pos<>0
    StringMid,char,upper,%pos%,1
  Else
  {   
    StringGetPos,pos,upper,%char%
    pos+=1
    If pos<>0
      StringMid,char,lower,%pos%,1
  }
  StringTrimLeft,string,string,1
  string=%string%%char%
}
Return %string%
}

Title(Title){
X = I,AHK,AutoHotkey

Title := RegExReplace(Title, "[\.\!\?]\s+|\R+", "$0ŝ") ; mark 1st letters of sentences with char 254
Loop Parse, Title, ŝ
{
   StringLower L, A_LoopField
   I := Chr(Asc(A_LoopField))
   StringUpper I, I
   S .= I SubStr(L,2)
}
Loop Parse, X, `,
   S := RegExReplace(S,"i)\b" A_LoopField "\b", A_LoopField)

Return %S%
}


It seems to work pretty well in Notepad, although cursory trying in Gmail shows erratic behavior sometimes requires 2 or 3 taps to change case and sometimes the case changed to, is not the proper one in the order. Oh well. This may be due to frequent background saves of messages by Gmail...

I did compile the program and make it available on one of my sites: http://www.godskingsandheroes.info/software/#shift-f3-case-changer

Update: 03/20/2010
I may have had two instances of the program running hence the need for two taps on the F3 key to advance to the next case. So it may be consistent after all Very Happy.
Back to top
View user's profile Send private message
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Mon Mar 22, 2010 11:17 am    Post subject: Added Code for Preserving the Clipboard Text Reply with quote

I added some code for preserving the clipboard text that I had found earlier. It appears to have first been suggested in the forum by Neobrew here: http://www.autohotkey.com/forum/viewtopic.php?t=23654, although for the experts or even an average programmer it's not too complicated I think.

Anyway, the changes are added to the script below, along with a filled in header I found by creating an empty new AutoHotKey file from the template found on the Windows New File and Folder Context Menu.
Code:

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         socrtwo <socrtwo@s2services.com>, "None" and "Lazslo" from the AutoHotKey forum, most of the coding of this script is by "None".  See - http://www.autohotkey.com/forum/viewtopic.php?t=55868
;
; Script Function: Summary: Change case in any Windows app by holding down the shift key and tapping F3. Details: In any Windows application thIs script translates holding down the shift key and tapping on f3 into cycling your selected text through invert, lower, upper, title and sentence cases.  This program uses the clipbaoard in order to carry out its function but returns at least the text that existed on the clipbaord in the beginning. This program copies the similar feature in MS Word that uses the same key combination. The feature in word omits the invert and sentence case but in word, these can be accessed from customizing the quick access toolbar. The script is mostly by none with the sentence case function by laszlo both from the AutoHotkey forum. The script idea was suggested and after minor synthesis and adjustment compiled by me socrtwo (paul d pruitt).
;   
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

State=0
*F3::
If !GetKeyState("Shift","P")
  Return
  Clip_Save:= ClipboardAll                                                 ; save original contents of clipboard
 Clipboard:= ""
Send ^x
StringReplace, Length, Clipboard, `r`n , `n, All
Len:=strlen(Length)
If State=0
 Changed:=Invert(Clipboard) ;call the Invert function
If State=1
 Stringlower, Changed, Clipboard
If State=2
 Stringupper, Changed, Clipboard
If State=3
 Stringlower, Changed, Clipboard ,T
If State=4
 Changed:=Title(Clipboard) ;call the Title function
State:=State<4 ? State+1 : 0
Clipboard:=Changed
Send ^v
Sleep 50
Clipboard:= ""
Clipboard:= Clip_Save
SendInput {Blind}{Left %Len%}
Return

INVERT(String){
AutoTrim,Off
StringCaseSense,On
lower=abcdefghijklmnopqrstuvwxyzĉĝċ
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZĈĜĊ
StringLen,INVlength,String

Loop,%INVlength%
{
  StringLeft,char,string,1
  StringGetPos,pos,lower,%char%
  pos+=1
  If pos<>0
    StringMid,char,upper,%pos%,1
  Else
  {   
    StringGetPos,pos,upper,%char%
    pos+=1
    If pos<>0
      StringMid,char,lower,%pos%,1
  }
  StringTrimLeft,string,string,1
  string=%string%%char%
}
Return %string%
}

Title(Title){
X = I,AHK,AutoHotkey

Title := RegExReplace(Title, "[\.\!\?]\s+|\R+", "$0ŝ") ; mark 1st letters of sentences with char 254
Loop Parse, Title, ŝ
{
   StringLower L, A_LoopField
   I := Chr(Asc(A_LoopField))
   StringUpper I, I
   S .= I SubStr(L,2)
}
Loop Parse, X, `,
   S := RegExReplace(S,"i)\b" A_LoopField "\b", A_LoopField)

Return %S%
}



Still to do is, is to preserve the clipboard even if it has an image or file on it.[/code]
Back to top
View user's profile Send private message
bruceshining
Guest





PostPosted: Wed Dec 08, 2010 8:04 pm    Post subject: it's not working... Reply with quote

Sad
I tried this by pasting it into my AutoHotkey.ahk file and then reloaded it.
It is not changing case and it IS messing up the text and moving the cursor to the left each time I press SHIFT F3.

Not so good. Sad
I am not into fixing it. Is there some better code to do this elsewhere?
Back to top
socrtwo



Joined: 17 Mar 2010
Posts: 13

PostPosted: Wed Dec 08, 2010 9:31 pm    Post subject: Maybe Better Source Code Reply with quote

https://sourceforge.net/projects/shiftf3/ - this may be better sourcecode. However, I think the problem of losing previous text is not corrected.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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