retaining selected data/text

Get help with using AutoHotkey and its commands and hotkeys
domino1952
Posts: 1
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: 718
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] [Download] GeSHi © Codebox Plus

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

Return to “Ask For Help”

Who is online

Users browsing this forum: rae, sam_663 and 32 guests