Insert clipboard

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Insert clipboard

Post by Akuro »

I know how to insert selected text with the \s switch, but is there something similar for inserting the clipboard content, such as \cp or any other way to get the current clipboard text inserted?

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

Akuro
Read about AkelPad Scripts methods in ...\AkelPad\AkelFiles\Docs\Scripts-Eng.txt:
AkelPad.GetClipboardText()
AkelPad.ReplaceSel()

Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Post by Akuro »

Thank you KDJ,
after reading about those 2 methods, I am still in the dark how to pull this off. Maybe it's best to nail it down step by step:

1) There is nothing similar to

Code: Select all

[b]\s[/b]

that would allow me to simply exchange the \s - part for say, \clipboard or something like that? Is this correct?

2) The clipboard text is read into a variable that I must declare up front, then call the method to fill it with the clipboard content. Still correct?

3) How do I get this variable into the parentheses of AkelPad.ReplaceSel()?

4) And how do I squeeze all of the above into my toolbar entry?

Would you please point me to other rescources that deal with 3) and 4) in particular. I could not find help material that would close that gap.
Thank you.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

Akuro
We can use the standard script EvalCmd.js for evaluate this expression (JScript):

Code: Select all

AkelPad.ReplaceSel("[b]" + AkelPad.GetClipboardText() + "[/b]");
Command for Hotkeys plugin:

Code: Select all

Call("Scripts::Main", 1, "EvalCmd.js", `AkelPad.ReplaceSel("[b]" + AkelPad.GetClipboardText() + "[/b]");`)
Command for Toolbar plugin:

Code: Select all

"Insert from clipboard" Call("Scripts::Main", 1, "EvalCmd.js", `AkelPad.ReplaceSel("[b]" + AkelPad.GetClipboardText() + "[/b]");`) Icon(9)
--------
Added:
Also you can save this expression in the file named eg. InsertFromClipboard.js (in directory ...\AkelPad\AkelFiles\Plugs\Scripts\) and use command:

Code: Select all

Call("Scripts::Main", 1, "InsertFromClipboard.js")

Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Post by Akuro »

GREAT. This works exactly the way I had hoped for. 8)
Was able to modify it to meet my needs. Could have never pulled this off on my own. Really appreciating your help. Many thanks. :D

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

Akuro
Insert.js

Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Post by Akuro »

Wow, that's even better. :o
Surpasses my expectations and opens up additional luxuries I didn't imagine possible.
THANK YOU.
Post Reply