Needs scripts for plain text paste and em dash Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kissinger
Posts: 5
Joined: 26 Apr 2018, 06:58

Needs scripts for plain text paste and em dash

26 Apr 2018, 07:00

These things are easy to do on MacOS with no need for AHK, but now that I'm on Windows I will needs scripts that would allow me to do both. Does anyone have either of these?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Needs scripts for plain text paste and em dash  Topic is solved

26 Apr 2018, 19:07

Here's some code. Cheers.

Code: Select all

q:: ;paste clipboard as plain text
Clipboard := Clipboard
SendInput, ^v
return

;note:
;vText := Clipboard stores the clipboard's plain text to a variable
;Clipboard := vText puts plain text onto the clipboard

w:: ;send em dash
SendInput, % Chr(A_IsUnicode ? 8212 : 151)
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
JoeWinograd
Posts: 2200
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Needs scripts for plain text paste and em dash

26 Apr 2018, 19:20

Hi kissinger,
You may find this thread from earlier this month about em dash and en dash to be helpful:
https://autohotkey.com/boards/viewtopic.php?f=5&t=46554
Regards, Joe
kissinger
Posts: 5
Joined: 26 Apr 2018, 06:58

Re: Needs scripts for plain text paste and em dash

28 Apr 2018, 11:33

Thanks both. Works great now.
User avatar
JoeWinograd
Posts: 2200
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Needs scripts for plain text paste and em dash

28 Apr 2018, 11:40

You're welcome...glad to hear it...thanks for letting us know. Cheers, Joe
kissinger
Posts: 5
Joined: 26 Apr 2018, 06:58

Re: Needs scripts for plain text paste and em dash

11 May 2018, 05:36

These scripts are still working fine, but I've noticed a quirk, which is that when I plain text paste large chunks of texts (e.g., several lines at a time) there is always a line break in the last line, which doesn't appear in the original copied section of text. Has anyone else noticed this? It might be a bug in Window for all I know, but it's certainly pretty annoying.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Needs scripts for plain text paste and em dash

11 May 2018, 07:26

Are you copying from Excel? Excel adds a trailing line break, you can remove trailing linefeed/carriage return characters like so:

Code: Select all

vText := RTrim(Clipboard, "`r`n")
Or to remove just the last line break:

Code: Select all

vText := Clipboard
if RegExMatch(vText, "`r`n$")
	vText := SubStr(vText, 1, -2)

;or:
vText := Clipboard
if (SubStr(vText, 1, StrLen(vText)-1) = "`r`n")
	vText := SubStr(vText, 1, -2)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RussF and 298 guests