在鼠标指针上写一条线并随之移动

时间:2014-06-09 16:01:15

标签: python xlib

我正在编写一个用于辅助功能目的的应用程序,需要在所有窗口顶部绘制一条跟随鼠标移动的线,我面临的问题是,在我让鼠标移动线后一段时间后消失所以用户很难看到这条线。我只能使用python-xlib

def createAbsoluteMouseEvent(x,y):
    #move pointer to set absolute location
    dis = display.Display()
    scr = dis.screen()
    win = scr.root
    data = win.get_geometry()
    height = data.height
    if lineActive:
        colormap = scr.default_colormap
        color = colormap.alloc_color(cred, cgreen, cblue)
        gc = win.create_gc(
            line_width = lineWidth,
            line_style = X.LineSolid,
            fill_style = X.FillOpaqueStippled,
            fill_rule  = X.WindingRule,
            cap_style  = X.CapButt,
            join_style = X.JoinMiter,
            foreground = color.pixel,
            background = scr.black_pixel,
            graphics_exposures = True,
            subwindow_mode = X.IncludeInferiors,
        )
        win.line(gc, x, 0, x, height)
    win.warp_pointer(x,y)
    dis.sync()

0 个答案:

没有答案