retaining selected data/text

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
domino1952
Posts: 4
Joined: 20 May 2018, 18:13

retaining selected data/text

20 May 2018, 18:58

Hi all,
I have a AHK script that manipulates clipboard data and sends the manipulated data back to the application.
In my example I am using Ctrl X to uppercase the selected text and send it back to the screen.

I want to be able to have the text still selected once the ahk scripts finishes. Currently the script retrieves the selected data, converts it to uppercase and redisplay it over the selected data but it is no longer selected. The send over writes the data on the screen, until that point it is still highlighted/selected.

Sample code below:

#SingleInstance force
#Persistent
SetTitleMatchMode, RegEx
SetTitleMatchMode, Slow

^x:: ; Ctrl XConvert text to upper
GetSelectedText()
StringUpper ClipBucket5, Clipboard
ClipBucket5 := RegExReplace(ClipBucket5, "\r\n?|\n\r?", "`n")
Send %ClipBucket5% ; send it back to application
RETURN


; Get the highlighted data into clipboard
; ---------------------------------------
GetSelectedText() {
tmp = %ClipboardAll% ; save clipboard
Clipboard := ""
Sendinput ^c ; simulate Ctrl+C (=selection in clipboard)
ClipWait, 0, 1 ; wait until clipboard contains data
}


Thanks for your help

Geoff
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: retaining selected data/text

20 May 2018, 19:53

the following is dumb hack territory:

Code: Select all

GetSelectedText()
StringUpper ClipBucket5, Clipboard
ClipBucket5 := RegExReplace(ClipBucket5, "\r\n?|\n\r?", "`n")
Len := StrLen(ClipBucket5)
Send %ClipBucket5% ; send it back to application
Send % "+{Left " Len "}" ; shift+left arrow to select as many times as the string has characters
domino1952
Posts: 4
Joined: 20 May 2018, 18:13

Re: retaining selected data/text

29 Jun 2018, 21:40

Thanks, I'll give it a try

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, GollyJer, Lamron750 and 258 guests