Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Monitor clipboard 1

Status
Not open for further replies.

PhilBreau

Technical User
Dec 14, 2001
108
CA
Is there a way for a script to monitor the clipboard? I want to paste the clipboard to another application. When the contents of the clipbaord changes Ie select and copy, I want to paste to the app again.

Thank you
 
If the data is always text and is less than 256 bytes long, you could use the cliptostr command to copy the clipboard to a string and then compare that string to a previous value you retrieved. If the strings are identical, then the data has not changed, but if they are different you know you have updated data in the clipboard. If the expected data is greater than 256 bytes, you could use the cliptofile command to save the data to a file, then read in that data chunk by chunk to determine if you have new data.

Here's a test script I wrote that uses cliptostr to get the clipboard data every five seconds. Then when sClip command will call the NewClip procedure whenever the data on the clipboard has been changed.

string sClip

proc main
when sClip call NewClip

while 1
cliptostr sClip
pause 5
endwhile
endproc

proc NewClip
usermsg "Clipboard now contains %s" sClip
endproc

aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top