Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done TCEDIT Clipboard Data

Aug
1,915
68
Ref: TCEDIT the Clipboard

The SPFLite Editor has a command line option that allows one to edit the clipboard, but with less keystrokes (and less user error) than in my example with TCEDIT.

From the TCC Command line, I do;
Code:
spflite2 -clip
...which starts spflite2 with the contents of the clipboard.

I make my modifications to the clipboard, exit, and my changes to the clipboard are now available for use elsewhere.

It would be convenient if TCEDIT had a /CLIP command line option that does the same thing.

From the SPFLite Help File;
-CLIP option

If '-CLIP' appears in the command line, SPFLite will operate in clipboard edit mode, which does the following:

The contents of the Windows clipboard are opened up into a Clipboard edit session when SPFLIte starts. This will directly edit the contents of the Windows clipboard, without any intermediate or temporary file involved.

When the primary Command END is entered, the current edit data is returned to the Windows clipboard.

Clipboard mode is designed to provide a quick, convenient means for editing clipboard data with the SPFLite command set. From outside SPFLite, it works most effectively if a separate icon is created for SPFLite that has a command-line operand of -CLIP. To create a CLIP icon on the desktop, copy the normal icon and add -CLIP as an operand, in the icon's Properties window. You can now click on the icon to directly edit the clipboard contents.

If SPFLite is already running, you can use the CLIP primary command to open a new tab containing the current clipboard contents.

Joe
 
What happens if the clipboard is empty, or has content but no text (say an image file)?
 
I just tried: tcedit clip:
And that worked - at least it brought up the text in the editor.
 
Well, saving the edited file doesn't put it back in the clipboard. But highlight and Ctrl+C does work.
 
Hmmm! I haven't yet found much of a use for TCC's THREAD command. This, ECLIP.BTM, basically works to put the file back in the clipboard.

Code:
if "%@clip[0]" == "**EOC**" quit
set tmpfile=%TMP\JPSCLIP.TXT
copy /q clip: %tmpfile
thread `start /wait d:\tc28\tcedit.exe %tmpfile & copy /q %tmpfile clip: & del /q %tmpfile`

There are some difficulties. I can't do it with my normal editor (TextPad) because the STARTed instance exits immediately if another is already running. Maybe the same thing would happen with TCDEIT.EXE (don't know if it can be configured for single/multiple instances). Can't use the internal TCEDIT because it doesn't wait (and STARTing it opens a new TCC). "%@clip[0]" == "**EOC**" may not be a perfect test for the clipboard [not] containing text (anyone know of a better one?). Also, note that the external TCEDIT.EXE knows nothing about CLIP:.
 
I have an old BTM file (2013) created by @JoeCaverly named clipfmt.btm that enumerates the formats of data in the clipboard.
But, it sure seems easy to do 'tcedit clip:', edit, then Ctrl+A Ctrl+C.
 
I have an old BTM file (2013) created by @JoeCaverly named clipfmt.btm that enumerates the formats of data in the clipboard.
But, it sure seems easy to do 'tcedit clip:', edit, then Ctrl+A Ctrl+C.
Found the BTM ... pretty cool. I was thinking of writing a _CLIPISTEXT plugin internal variable
 
Here's the link to my 32-bit jlcClipboard plugin.

If asked, I will endevour to create a 64-bit version of said plugin.

Joe
 
What happens if the clipboard is empty, or has content but no text (say an image file)?
Well, before I edit the clipboard, I do a;
Code:
type clip: > clip:
...which converts whatever was in the clipboard into text.

If the clipboard has an image file;
Code:
e:\utils>tcedit clip:
TCC: Clipboard is not text format

e:\utils>type clip: > clip:
TCC: Clipboard is not text format

e:\utils>tcedit clip:
...then TCEDIT brings up an empty editor.

Also Ref: Detect Clipboard Format which I believe is what @samintz was referring to.

Joe
 
Code:
if "%@clip[0]" == "**EOC**" quit
set tmpfile=%TMP\JPSCLIP.TXT
copy /q clip: %tmpfile
thread `start /wait d:\tc28\tcedit.exe %tmpfile & copy /q %tmpfile clip: & del /q %tmpfile`

That basically works, but it had problems. "%@clip[0]" == "**EOC**" wasn't a good test of clipboard format. So I modified @Joe Caverly's script (thanks!) to test for text in the clipboard. And it failed when I threw in SETLOCAL because the BTM ended, taking with it the %tmpfile variable while the thread was still running. So I just cleaned up manually. I also used a unique filename.

Now I have this. It works pretty well.

Code:
:: ECLIP.BTM
switch %@exec[gosub clipistext]
    case 0
        echoerr ECLIP.BTM: Wrong format in clipboard
    case -1
        echoerr ECLIP.BTM: Couldn't open clipboard
    case 1
        set fn=%@unique[%tmp,ECL]
        copy /q clip: %fn
        thread `start /wait d:\tc28\tcedit.exe %fn & copy /q %fn clip: & del /q %fn & unset /q fn`
endswitch
unset /q rv uFormat junk
quit

:clipistext
if %@winapi[user32.dll,OpenClipboard,0] LE 0 return -1
set rv=0
set uFormat=0
do until %uFormat == 0
    set uFormat=%@winapi[user32.dll,EnumClipboardFormats,%uFormat]
    if %uFormat == 1 .or. %uFormat == 7 .or. %uFormat == 13 (set rv=1 & leave)
enddo
set junk=%@winapi[user32.dll,CloseClipboard]
return %rv
 
Does
start /wait /pgm textpad /m %tmpfile
help?
No. As I said, if TextPad is already running, the STARTed one exits immediately and the file opens in the already running one.
 
No. As I said, if TextPad is already running, the STARTed one exits immediately and the file opens in the already running one.

Not here.

If, in TextPad,
Configure | Preferences | General | Allow multiple instances to run
is set,
start /wait /pgm textpad
(with or witout /m ) always starts a new instance of TextPad and waits.

If, in TextPad,
Configure | Preferences | General | Allow multiple instances to run
is not set,
start /wait /pgm textpad
opens an existing instance of TextPad and does not wait.
start /wait /pgm textpad /m
starts a new instance of TextPad and waits.

Windows 11
TCC 26.02.43 x64
TextPad 8.9.0
 
Got it! I like/use single instance TextPad and I didn't know there was a command line option to override it. Thanks @ben.
 

Similar threads

Back
Top