Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Hotkey to move insertion point to end of sentence?



  • Please log in to reply
16 replies to this topic
poetofpiano
  • Members
  • 109 posts
  • Last active: Jan 25 2016 08:03 PM
  • Joined: 07 Apr 2013

In both Google Chrome and WordPerfect, this script doesn’t move the caret to the next sentence. It just highlights to the end of the word the caret was on when I sent the script. Not sure why 



nausher
  • Members
  • 8 posts
  • Last active: Jan 25 2014 01:29 AM
  • Joined: 23 Jul 2010

I took up AfterLemon's script and made some changes -

 

(i) 'Bug fixed' the premature stop at end of word.

(ii) Since Ctrl+Shift+Right can overshoot the character we are looking for so, added a correction to select back to the correct location

(iii) As AfterLemon mentioned this script can end up in an endless loop if doesn't find a period '.' character (or '/' in my script). to avoid this I have a check to ensure the loop terminates after 15 iterations. You can decide to change this to suit your taste.

 

Please also feel free to modify the RegEx search string. As I am also having it stop at backslashes '\' .

;>>>>>>>>>>>>>>>>>>>>>>>>>>> EMACS Style Select till end of sentence <<<<<<<<<<<<<<<<<<<<
<!k::
	ClipboardOld := ClipboardAll
	Clipboard := ""
	InsertPoint := 0
	InsertPoint2 := 0
	ClipboardFirst := ""
    Length := 0
	Loop
	{
		Send, ^+{Right}
		A_Index2 := A_Index
		Send, ^c
		Sleep, 20
		Length := StrLen(Clipboard)
		InsertPoint := RegExMatch(Clipboard,"[\.\\]")
        ;MsgBox, InsertPoint %InsertPoint% ; for debugging
		If (InsertPoint = 0) 
        {
            If (A_Index2 >= 15)
            {
                break
            }
            continue
        }
        else
        {
			break
        }
	}
    ; Since we may overshoot the . or other special character by use of Ctrl + -> in Windows
    ; we have to Shift + <- back by how much we overshot
    If(InsertPoint > 0 && InsertPoint <> Length)
    {
     GoLeftBy := Length - InsertPoint
     Loop %GoLeftBy%
     {
        Send, +{Left}
     }
    }
	Clipboard := ClipboardOld
	ClipboardOld := ""
return