Re: Code works absolutely fine but it also remove line break in normal copy and paste Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
shoun2502
Posts: 9
Joined: 13 May 2021, 10:32

Code works absolutely fine but it also remove line break in normal copy and paste

Post by shoun2502 » 28 Jan 2022, 17:29

Code: Select all

^+g:: MouseClick, left,  278, 182, 3 Send, {Shift down} MouseClick, left,  553, 212, 1 Send, {Shift up} Send, {Click, 1}^c OnClipboardChange: ToolTip Clipboard data type: %A_EventInfo% StringReplace, Clipboard, Clipboard,  `r`n,%A_Space%, All  Sleep 500 ToolTip  ; Turn off the tip. return
Hi Team,
If anyone could please help me with this. It would indeed be helpful.

Actually the above code works absolutely fine in copying the text removing line break but it also stops the use of Normal copy and paste with the line breaks.
I am looking for a solution wherein Ctrl C and Ctrl V should works as per normal behavior with line breaks
And Ctrl+shift+G should only execute that code which removes linke break

I look forward to having your resolution as it takes a lot of time as I have to stop the script everytime to perform normal copy and paste operations.

I am using Windows 10 and AHK Version 1.1.33.09
Last edited by shoun2502 on 28 Jan 2022, 18:10, edited 1 time in total.

braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: Code works absolutely fine but it also remove line break in normal copy and paste  Topic is solved

Post by braunbaer » 28 Jan 2022, 18:09

Code: Select all

^+g::
modifyclip:=true
MouseClick, left,  278, 182, 3
Send, {Shift down}
MouseClick, left,  553, 212, 1
Send, {Shift up}
Send, {Click, 1}^c
sleep 500
modifyclip:=false

OnClipboardChange:
if !modifyclip
   return
ToolTip Clipboard data type: %A_EventInfo%
StringReplace, Clipboard, Clipboard,  `r`n,%A_Space%, All
ToolTip  ; Turn off the tip. return

Last edited by braunbaer on 28 Jan 2022, 18:11, edited 1 time in total.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Code works absolutely fine but it also remove line break in normal copy and paste

Post by amateur+ » 28 Jan 2022, 18:11

Code: Select all

^+g::
MouseClick, ,  278, 182, 3 
Send, {Shift down} 
MouseClick, ,  553, 212
Send, {Shift up} 
Clipboard := ""
Send, {Click}^c 
ClipWait, 1
if ErrorLevel
	return
ToolTip Clipboard data type: %A_EventInfo% 
SetTimer, RemoveGToolTip, -500
tempClip := Clipboard
Clipboard := StrReplace(tempClip, "`r`n", A_Space)
tempClip := ""
return

RemoveGToolTip:
ToolTip
return
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

shoun2502
Posts: 9
Joined: 13 May 2021, 10:32

Re: Code works absolutely fine but it also remove line break in normal copy and paste

Post by shoun2502 » 28 Jan 2022, 18:30

Thanks @braunbaer and @amateur+ for your prompt response.
Both the codes works well and does the work.

Thanks a ton :bravo:

Post Reply

Return to “Ask for Help (v1)”