How to modify so that I can insert multi lines strings Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pgeugene
Posts: 40
Joined: 27 Jun 2019, 04:36

How to modify so that I can insert multi lines strings

09 Apr 2024, 02:26

Below is the script
After pressing the hotkey {^;} , a menu pop up so that I can select the items using Up|Down keys and hit {Enter} which will paste the selected string into my Text Editor
Currently all strings are in single line.
I have tried to make it into multi lines strings by using "Hello, How are you?`nHello"
I expect the strings I inserted to be like below.

Hello, How are you?
Hello

Now The string after`n turned into another new string instead

However the end result became like attached file

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;*******************************************************
; Want a clear path for learning AutoHotkey; Take a look at our AutoHotkey Udemy courses.  They're structured in a way to make learning AHK EASY
; Right now you can  get a coupon code here: https://the-Automator.com/Learn
;*******************************************************
#Requires AutoHotkey v1.1
#SingleInstance,Force
; To add new content add the pipe ¦ at the begning of a new line for what you want to have in here and reload

Text=
(
¦This is an example
¦Hello, How are you?`nHello
)
sort,text ;If you'd like it alphabatized

^;::  ;when hit Control+Shift+L the menu will appear.  Arrow up/down to select one and hit enter
TextMenu(Text) ;Trigger TextMenu function with text
return

TextMenu(TextOptions){
	for k, MenuItems in StrSplit(TextOptions,"¦")  ;parse the data on the weird pipe charachter
		Menu, MyMenu,Add,% trim(MenuItems),Action ;Add each item to the Menu
	
	Menu, MyMenu, Show ;Display the GUI and wait for action
	Menu, MyMenu, DeleteAll ;Delete all the menu items
}

Action:
ClipboardBackup:=ClipboardAll ;backup clipboard
Clipboard:=""
Clipboard:=A_ThisMenuItem ;Shove what was selected into the clipboard
ClipWait,1
Send, ^v ;paste the text
sleep, 100 ;Remember to sleep before restoring clipboard or it will restore the clipboard before pasting
Clipboard:=ClipboardBackup ;Restore clipboard
return

Attachments
image.png
image.png (2.06 KiB) Viewed 98 times
Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to modify so that I can insert multi lines strings  Topic is solved

09 Apr 2024, 04:08

Hallo,
replace

Code: Select all

sort,text
by

Code: Select all

sort,text,D¦
pgeugene
Posts: 40
Joined: 27 Jun 2019, 04:36

Re: How to modify so that I can insert multi lines strings

10 Apr 2024, 01:30

Thank you
It is working as expected

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Descolada and 169 guests