Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using the clipboard for communicatign between programs
#1
a simple example of using the clipboard to communicate between programs.

This example requires three programs Clipmaster ,cliptalk1, and cliptalk2.
Compile all three and save them in the same directory to see how this works. 

I almost certainly lifted the idea from somewhere else but I can't recall where, sorry if I'm failing to give proper credit.

Clipmaster
Code: (Select All)
'Clipmaster
'clipboard communication sample
'
'CTA talk to all the cliptalk programs
'CT1 talk to cliptalk1
'CT2 talk to cliptalk2
'QUITALL ends all the programs

_Title "CLIPMaster"
Shell _DontWait "cliptalk1.exe /RUN"
Shell _DontWait "cliptalk2.exe /RUN"
Do
    Line Input "Enter some text to send to other program: ", text$
    If text$ = "QUITALL" Then Exit Do
    If UCase$(text$) = "CLEAR" Then _Clipboard$ = ""
    _Clipboard$ = text$
Loop
_Clipboard$ = "CTAQUITALL"

System

Cliptalk1
Code: (Select All)
'cliptalk1
Screen _NewImage(40, 20, 0)
_Title "CLIPTALK1"
Print "Reading text from clipboard."
Print " Esc key quits!"
MYID$ = "CT1"
Do: _Limit 100
    text$ = _Clipboard$ 'function returns clipboard contents
    If Len(text$) And text$ <> lasttext$ Then
        If text$ = "CTAQUITALL" Then GoTo QEXIT
        If Left$(UCase$(text$), 3) = "CTA" Then lasttext$ = text$
        If Left$(UCase$(text$), 3) = MYID$ Or Left$(UCase$(text$), 3) = "CTA" Then
            tt$ = Left$(UCase$(text$), 3)
            text$ = Right$(text$, Len(text$) - 3)
            Print text$
            If tt$ = MYID$ Then _Clipboard$ = "" 'clear clipboard after a read
        End If
    End If
Loop Until InKey$ = Chr$(27)
QEXIT:
System
End

cliptalk2
Code: (Select All)
'cliptalk2
Screen _NewImage(40, 20, 0)
_Title "CLIPTALK2"
Color 0, 15
Cls
Print "Reading text from clipboard."
Print " Esc key quits!"
MYID$ = "CT2"
Do: _Limit 100
    text$ = _Clipboard$ 'function returns clipboard contents
    If Len(text$) And text$ <> lasttext$ Then
        If Left$(UCase$(text$), 3) = "CTA" Then lasttext$ = text$
        If text$ = "CTAQUITALL" Then GoTo QEXIT
        If Left$(UCase$(text$), 3) = MYID$ Or Left$(UCase$(text$), 3) = "CTA" Then
            tt$ = Left$(UCase$(text$), 3)
            text$ = Right$(text$, Len(text$) - 3)
            Print text$
            If tt$ = MYID$ Then _Clipboard$ = "" 'clear clipboard after a read
        End If
    End If
Loop Until InKey$ = Chr$(27)
QEXIT:
System
End
Reply


Messages In This Thread
using the clipboard for communicatign between programs - by James D Jarvis - 10-22-2022, 03:05 AM



Users browsing this thread: 2 Guest(s)