issue with SendEvent Clipboard Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Prisonfeed
Posts: 8
Joined: 24 Aug 2017, 10:59

issue with SendEvent Clipboard

24 Jun 2018, 15:17

I have a Windows program that I like to paste to quite often. However it doesn't allow pasting, so I use AHK as follows...

Code: [Select all] [Download] GeSHi © Codebox Plus

F4::
gosub SendClipboardTextCharacters
return

SendClipboardTextCharacters:

SetKeyDelay,10
SendEvent % StrReplace(Clipboard,"`r")

return


It removes the 'r because Windows likes to use 'r'n which results in double line returns. Everything was great, but now the program has updated. All the lines become indented (a built in "Feature" in the software). One way I can get around this awful "feature", which can't be disabled, is to hit the HOME key after every line return.

I tried replacing 'r'n with 'n{home}.

Code: [Select all] [Download] GeSHi © Codebox Plus

SendClipboardTextCharacters:

SetKeyDelay,10
SendEvent % StrReplace(Clipboard,"`r{home}")

return

This does return the cursor to the front of the line, however it writes {home} at the front of every line.

First Line
{home}Line 2
{home}line 3
{home}line 4



How can I sent a HOME key press after every line return without actually writing {home} at the front of every line?
User avatar
Xtra
Posts: 1138
Joined: 02 Oct 2015, 12:15

Re: issue with SendEvent Clipboard  Topic is solved

24 Jun 2018, 18:43

Try:
SendEvent % StrReplace(Clipboard,"`r") . "{Home}"

HTH
User avatar
Nextron
Posts: 1149
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: issue with SendEvent Clipboard

24 Jun 2018, 19:11

Prisonfeed wrote:I tried replacing 'r'n with 'n{home}
Good pseudo code, but that's not reflected in the snippet you posted. It may even be better to replace it with 'n+{home} so you select the indentation whitespace characters, which will get overwritten, opposed to aggregating at the end of your 'pasted' text: SendEvent % StrReplace(Clipboard,"`r`n","`r+{home}")

however it writes {home} at the front of every line
Does the clipboard text happen to have the string {Raw} or {Text} on the first line?
The more I know:
The more I know,
I know nothing.
Prisonfeed
Posts: 8
Joined: 24 Aug 2017, 10:59

Re: issue with SendEvent Clipboard

24 Jun 2018, 20:08

Woohoo!! That did it!!!

I tried a dozen different ways, and I just could not get it to work.

Thank YOU!!
User avatar
jeeswg
Posts: 4595
Joined: 19 Dec 2016, 01:58
Location: UK

Re: issue with SendEvent Clipboard

24 Jun 2018, 21:12

I would imagine that something like this would avoid any issues with sending special characters:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: valuex and 66 guests