sjw重写加强版-解决 google chrome 浏览器里复制的内容不能粘贴到vmware workstation虚拟机里的问题 博客分类: vmwareubuntu google chrome 浏览器复制不能粘贴vmware workstation
程序员文章站
2024-03-26 10:36:11
...
解决 google chrome 浏览器里复制的内容不能粘贴到vmware workstation虚拟机里的问题,之前的程序见http://sjwpython.iteye.com/blog/2119756 这里,今天重写改进了下,修正多次对同一内容ctrl+c 不触发辅助程序执行的bug,省去了安装xsel工具,提高程序效率。
sjw原创分享,转载请注明出处:http://sjwpython.iteye.com/blog/2252843
from gi.repository import Gtk, Gdk import subprocess import time CHROME_WINDOW='Google Chrome' pre_time=time.time() def sjwCP(*args): ’‘’ sjw 2015-10-28 ''' global pre_time task = subprocess.Popen("xdotool getactivewindow getwindowname", shell=True, stdout=subprocess.PIPE) winID = task.stdout.read().rstrip('\n') now_clip_info=args[0].wait_for_text() now_time=time.time() if (winID.endswith(CHROME_WINDOW)) and (now_time-pre_time>0.1): if(now_clip_info): args[0].set_text(now_clip_info,-1) pre_time=time.time() clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clip.connect('owner-change',sjwCP) Gtk.main()