コード例 #1
0
ファイル: Clicker.py プロジェクト: Maxim-nwb/Clicker
def main():
    window = GUI.Tk()
    my_gui = GUI.MainWindow(window)
    keyboard.on_press(lambda x: pressed(x, my_gui))
    mouse.on_button(callback=pressed,
                    args=("c", my_gui),
                    buttons=('left', 'middle', 'right'),
                    types=('down', 'double'))
    window.mainloop()
コード例 #2
0
    def __init__(self, master):
        self.master = master  #so that another method to access it
        self.active = StringVar()
        self.active.set("INACTIVE")
        self.speed = IntVar()
        self.speed.set(25)

        hyperlink = Label(master,
                          text="Source Code",
                          fg="blue",
                          cursor="hand2")
        hyperlink.grid(row=1, column=0, sticky=W)
        hyperlink.bind(
            "<Button-1>", lambda x: webbrowser.open_new(
                r"https://github.com/aelna354/mypythonautoclicker"))

        Label(master, text="Seconds between clicks").grid(row=2,
                                                          column=0,
                                                          sticky=W)

        speedframe = Frame()
        speed = [.025, .05, .25, .5, 1]
        for pos, i in enumerate(speed):
            Radiobutton(speedframe,
                        text=i,
                        variable=self.speed,
                        value=int(i * 1000)).grid(row=0, column=pos)
        speedframe.grid(row=2, column=1, sticky=W)

        self.status = Entry(master, textvariable=self.active, fg="red")
        self.status.configure(state="readonly")
        self.status.grid(row=3, column=0, sticky=W)

        Label(master,
              fg="black",
              bg="silver",
              text="Press either F3 or F4 to toggle the program.\n" +
              "You can also stop the program with the RMB.\nNOTE: You cannot" +
              " change speed while program is active.").grid(row=4,
                                                             column=0,
                                                             columnspan=3,
                                                             sticky=W)

        keyboard.add_hotkey("F3", self.toggle)
        keyboard.add_hotkey("F4", self.toggle)
        mouse.on_button(self.stop, buttons='right')
コード例 #3
0
ファイル: find_times.py プロジェクト: 56kyle/legends
def record_and_save(file):
    timer = Timer()
    mimic = Mimic()
    buttons = (mouse.LEFT, mouse.MIDDLE, mouse.RIGHT, mouse.X, mouse.X2)
    values = (mouse.UP, mouse.DOWN, mouse.DOUBLE)
    for button in buttons:
        for val in values:
            mouse.on_button(mimic.record,
                            args=(button, val),
                            buttons=(button, ),
                            types=(val, ))

    keyboard.on_press_key("`", mimic.end_recording)

    while mimic.recording:
        pass
    else:
        mimic.save("throw_daggers")
コード例 #4
0
 def change_toggle_mouse(self):
     """
     Change the mouse hotkey
     """
     self.remove_toggle_mouse()
     if self.toggle_selection == 'Left Click':
         button = mouse.LEFT
     elif self.toggle_selection == 'Right Click':
         button = mouse.RIGHT
     elif self.toggle_selection == 'Middle Click':
         button = mouse.MIDDLE
     elif self.toggle_selection == 'Mouse4':
         button = mouse.X
     elif self.toggle_selection == 'Mouse5':
         button = mouse.X2
     self.mouse_hotkey = mouse.on_button(self.toggle_signal.emit,
                                         buttons=button,
                                         types=mouse.UP)  # add mouse hotkey
コード例 #5
0
    print('callback x')


def callback_x2():
    print('callback x2')


X = 'x'
X2 = 'x2'

UP = 'up'
DOWN = 'down'

# mouse.on_middle_click(callback, args=())

mouse.on_button(callback_x, args=(), buttons=(X, ), types=(DOWN, ))
mouse.on_button(callback_x2, args=(), buttons=(X2, ), types=(DOWN, ))

from pynput import mouse

while True:
    time.sleep(0.01)

    with mouse.Events() as events:
        # Block at most one second
        event = events.get(1.0)
        if event is None:
            print('You did not interact with the mouse within one second')
        else:
            print('Received event {}'.format(event))
コード例 #6
0
ファイル: handler_mouse.py プロジェクト: RavenVl/steelMouse
import mouse
import time


def handle_click(*args, **kwargs):
    print('Press!!!')


# mouse.on_click(lambda: print("Left Button clicked."))
# mouse.on_right_click(lambda: print("Right Button clicked."))
mouse.on_button(callback=handle_click, buttons=['x'], types=['up'])
time.sleep(5)
コード例 #7
0
def downCallback():
    xValOld, yValOld = mouse.get_position()
    list[0] = xValOld
    list[1] = yValOld
    # print(xValOld ,' ', yValOld, ' pressed')


def upCallback():
    xVal, yVal = mouse.get_position()
    # print(xVal ,' ', yVal, ' released')
    # print(list)
    # print('\b' * list[2], end='', flush=True)
    printString = '({0}, {1}, {2}, {3})'.format(list[0], list[1],
                                                xVal - list[0], yVal - list[1])
    list[2] = len(printString)
    print(printString)


mouse.on_button(downCallback, (), mouse.LEFT, mouse.DOWN)

mouse.on_button(upCallback, (), mouse.LEFT, mouse.UP)

# while True:
#     x, y = mouse.get_position()
#     positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
#     print(positionStr, end='')
#     print('\b' * len(positionStr), end='', flush=True)

mouse.wait(button=None, target_types=None)
コード例 #8
0
 def get_mouse_position_on_click(self, ui_field):
    mouse.on_button(self._get_mouse_position_on_click, [ui_field], [mouse.LEFT], [mouse.UP])