X11获取剪贴板文本 [英] X11 Get Clipboard Text
问题描述
我要监视剪贴板X11
有关的那一刻,我要求剪贴板选择每5秒钟,然后我哈希文本从剪贴板回来,我从上次检查的哈希计算进行比较。如果哈希值是不一样的,我分析的文本内容,并做一些东西...
我不喜欢我的方法。我从Windows敢,并用WINAPI,它是当剪贴板中已经改变了通知你的程序内核,它是更有效的!
我只是想知道是否有可能是X11可以通知你的程序为WINAPI时剪贴板发生了变化?什么是检查与X11剪贴板修改的更有效的方法?
- 找到与选择使用窗口
GetSelectionOwner
(PRIMARY和剪贴板) - 通过发送SelectionRequest,通知你的应用程序中获取的选择副本
- 手表
SelectionClear
事件 - 使用ID选择从
SelectionClear
事件,转到第2步 更新窗口
I have to monitor the X11 Clipboard.
For the moment, I request the ClipBoard Selection each 5 seconds, then I hash the text returned from clipboard and I compare it with the hash calculate from the last check. If hash are not the same, I analysis the text content and do some stuff...
I don't like my method. I'm from Windows, and with the winapi, it is the kernel that notify your program when the clipboard has changed, and it's more efficient!
I just want to know if it is possible that X11 can notify your program as winapi when the clipboard has changed ? What is the more efficient way to check clipboard modifications with X11 ?
- Find window with selection using
GetSelectionOwner
(PRIMARY and CLIPBOARD) - get copy of selection by sending SelectionRequest, notify your application
- watch for
SelectionClear
event - update window with selection using id from
SelectionClear
event, goto step 2
这篇关于X11获取剪贴板文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!