美文网首页
python 获取鼠标全局动作

python 获取鼠标全局动作

作者: zmc_94d8 | 来源:发表于2017-10-29 11:16 被阅读0次

    import struct

    file = open( "/dev/input/mice","rb" );

    def getMouseEvent():

        buf= file.read(3);

        button = ord( buf[0] );

        bLeft = button & 0x1;

        bMiddle = ( button & 0x4 ) > 0;

        bRight = ( button & 0x2 ) > 0;

        x,y= struct.unpack( "bb", buf[1:] );

        print ("L:%d, M: %d, R: %d, x: %d, y: %d\n" %(bLeft,bMiddle,bRight, x, y) );

        #return stuffs

    while( 1 ):

    getMouseEvent();

    file.close();

    相关文章

      网友评论

          本文标题:python 获取鼠标全局动作

          本文链接:https://www.haomeiwen.com/subject/dimtuxtx.html