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
retaining selected data/text
-
- Posts: 4
- Joined: 20 May 2018, 18:13
Re: retaining selected data/text
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
-
- Posts: 4
- Joined: 20 May 2018, 18:13
Re: retaining selected data/text
Thanks, I'll give it a try