def mouse_click(self, button='Left', x=None, y=None, clicks=1, interval=0): pyvinyl.auto_delay() if (x != None or y != None): pos = pyvinyl.vinyl.get_mouse_pos(self.win) if (x == None): x = pos[0] if (y == None): y = pos[1] pyvinyl.vinyl.move_to(self.win, x, y) clicks_num = 0 while(clicks_num<clicks): if(ButtonCode[button] == ButtonCode.Left): pyvinyl.vinyl.left_click(self.win) elif(ButtonCode[button] == ButtonCode.Right): pyvinyl.vinyl.right_click(self.win) elif(ButtonCode[button] == ButtonCode.Middle): pyvinyl.vinyl.middle_click(self.win) if(interval>0): pyvinyl.sleep(interval) clicks_num = clicks_num + 1
def draw_circle(win): r = 300 x0 = 512 y0 = 384 x = 0 y = 0 n = 0 while n < 3.1415926 * 2: x = x0 + r * math.cos(n) y = y0 - r * math.sin(n) win.mouse_move_to(int(x), int(y)) pv.sleep(20) n = n + 0.03
y0 = 384 x = 0 y = 0 n = 0 while n < 3.1415926 * 2: x = x0 + r * math.cos(n) y = y0 - r * math.sin(n) win.mouse_move_to(int(x), int(y)) pv.sleep(20) n = n + 0.03 # 点击编辑界面的注释按钮,即可看到比较详细的脚本说明 pv.DELAY = 0 win = pv.new_window("notepad") pv.sleep(2000) StringDelay = 1000 # 最大化写字板 win.key_down(pv.KeyCode.LeftAlt) win.key_down(pv.KeyCode.Space) pv.sleep(500) win.key_press(pv.KeyCode.X) pv.sleep(500) win.key_up(pv.KeyCode.Space) win.key_up(pv.KeyCode.LeftAlt) win.say_string("hi,你好,我是<按键精灵>,我是个很有趣的软件,如果你愿意花5分钟的时间来了解我,你一定会喜欢上我的。 :-)\n", StringDelay) win.say_string("愿意了解我吗?如果愿意,请你按下键盘上的Y键,如果不喜欢我,那就按下键盘上的N键(等待按键...)\n", StringDelay)
def auto_delay(): if (pyvinyl.DELAY > 0): pyvinyl.sleep(pyvinyl.DELAY)
def message_box(self, content): pyvinyl.vinyl.message_box(self.win, content) if (pyvinyl.DELAY > 0): pyvinyl.sleep(pyvinyl.DELAY)