Trigger event when content on system clipbooard changes
1 回表示 (過去 30 日間)
古いコメントを表示
Hi!
I would like to trigger an event and code when the content of the clipboard changes.
I am creating polygons in a GIS-software by using a built in function of that software which captures X and Y coordinates when clicking in a map and sends these coordinates in a standadized manner to the system clipboard. Currently I'm manually pasting these coordinates into an excel sheet column and then use a script to create a SQL-string which is re-imported into the GIS-software.
I would like to initiate a MATLAB listener which triggers when the content of the system cliipboard (i.e. the clipboartd('paste') ) changes so I can automate the whole process and create the SQL-string when e.g. pressing TAB three times in a row. That bit with the TAB I've got nailed down - but the part where an event triggers when the system cliupboard changes has got me stumped.
I believe that I have to create a custom class and create a observable property for the clipboard. I can then listen for changes on that property. But how would I make the property dynamically/automatically update when the system clipboard changes? Is there a way to do this?
I guess one way would be to create a timer and every say two seconds get the value of the clipboard and update the property - but I would very much prefer not to do it this way.
My difficulty may also in no small part be that I'm really a Naval Architect and in all honesty have very little experience in programming with classes. =)
Anyone got some ideas to do this? Or is it impossible and should I just go for the option with the timer instead?
Best regards
//Martin
0 件のコメント
採用された回答
chrisw23
2023 年 10 月 24 日
asm = NET.addAssembly("System.Windows.Forms");
% Includes clipboard-class.
fCol = System.Collections.Specialized.StringCollection();
fInfo = System.IO.FileInfo("C:\Temp\dummy.txt");
fCol.Add(fInfo.FullName);
fClipboard = System.Windows.Forms.Clipboard;
fClipboard.SetFileDropList(fCol);
% Static methods:
%
% Clear ContainsFileDropList GetAudioStream GetFileDropList ReferenceEquals SetDataObject SetText
% ContainsAudio ContainsImage GetData GetImage SetAudio SetFileDropList
% ContainsData ContainsText GetDataObject GetText SetData SetImage
Here's an example how to access the clipboard class in Matlab. Unfortunately there's no event suited for your needs but a bunch of methods you could poll periodically. Check options by methodsview or details cmd.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!