コード例 #1
0
 def __init__(self):
     if not os.path.isfile(self.file_name):
         self.create_default_file()
     with open(self.file_name, 'r') as config:
         for line in config:
             if line != '':
                 code = line.split(';')[0]
                 value = self.get_key(line.split(';')[1].replace('\n',''))
                 if code == 'controller_sensitivity':
                     self.controller_sensitivity = float(value)
                 else:
                     self.buttons.append(Button(code, value))
コード例 #2
0
 def control_mouse(self, data):
     if len(data) == 2:
         x, y = data
         self.mouse.position = (int(x), int(y))
     elif len(data) == 4:
         x, y, dx, dy = data
         self.mouse.position = (int(x), int(y))
         self.mouse.scroll(100 * int(dx), 100 * int(dy))
     else:
         x, y, n1, n2, pressed = data
         button = Button((int(n1), int(n2)))
         self.mouse.position = (int(x), int(y))
         if pressed == "pressed":
             self.mouse.press(button)
         else:
             self.mouse.release(button)
コード例 #3
0


def submit ():
    global url1
    global game_code
    global user_name
    url1 = url_entry.get()
    game_code = game_entry.get()
    if terry_true.get() == 1:
        user_name = 'Terry'
    else:
        user_name = name_entry.get()
    root.destroy()

see_user_manual = Button(root, text="Do you want to see the user manual", font=("arial", 15), bg="#1de02a", command=show_user_manual)
spacer = Label(root,text='')
spacer2 = Label(root,text='')
url_label = Label(root, text="Please copy paste URL below:", font=("Arial",15), bg='#7a2aa8')
url_entry = Entry(root, width=50, font=("Arial",15), borderwidth=7)

gamecode_label = Label(root, text="Please type game code below:", font=("Arial",15), bg='#7a2aa8')
game_entry = Entry(root, width=50, font=("Arial",15), borderwidth=7)

name_label = Label(root, text="Please type your name below:", font=("Arial",15), bg='#7a2aa8')
name_entry = Entry(root, width=50, font=("Arial",15), borderwidth=7)
terry_true = IntVar()
terry_box = Checkbutton(root, text="Terry", variable=terry_true)

submit_btn = Button(root, text="Submit", font=("arial", 15), bg="#1de02a", command=submit)
コード例 #4
0
						if point[3] == 'a':
							if point[2] == 'r': k.release(point[5:])
							if point[2] == 'r': k.press(point[5:])
						elif point[3] == 's':
							if point[2] == 'r': k.release(eval(point[5:]))
							if point[2] == 'r': k.press(eval(point[5:]))

def start_server_thread(ip, port):
	main_server_thread = threading.Thread(target=start_server, args=(ip.get(), port.get()))
	main_server_thread.start()

tk_window = Tk()
tk_window.geometry('200x150')
tk_window.title('Sinkron')

ip_label = Label(tk_window, text="IP Adress").grid(row=0, column=0)
ip = StringVar()
ip_entry = Entry(tk_window, textvariable=ip).grid(row=0, column=1)

port_label = Label(tk_window, text="Port").grid(row=1, column=0)
port = StringVar()
port_entry = Entry(tk_window, textvariable=port).grid(row=1, column=1)

start_server_thread = partial(start_server_thread, ip, port)

start_server_button = Button(tk_window, text="Start Server", command=start_server_thread).grid(row=4, column=0)

tk_window.mainloop()

# -
コード例 #5
0
non_premium_clicked = IntVar()
Checkbutton(frame_premium, text="Non-Premium",
            variable="non_premium_clicked").grid(row="5", column="5")

# This is the menu for the specs

frame_specs = LabelFrame(window, text="Specs", padx=5, pady=5)
frame_specs.place(x=233, y=105)
specs_clicked = StringVar()
specs_clicked.set(specs_menu[1])
specs = OptionMenu(frame_specs, specs_clicked, *specs_menu)
specs.grid(row=3, column=2)

# This is the button for more info about specs

photo = PhotoImage(
    file=r"C:\Users\PC\Desktop\python hustlecastle bot\icons8-info-26.png")
info_button = Button(frame_specs, image=photo, command=new_window)
info_button.grid(row=3, column=3)

# This is the footer

credits = Label(window, text="Made by Luscsus").place(x=5, y=327)

# This is the button for starting the code

button = Button(window, text="Start", command=click, padx=15, pady=10)
button.place(x=300, y=300)

window.mainloop()
コード例 #6
0
            cx2 = x2 + w2 // 2
            cy2 = y2 + h2 // 2
            cx = (cx1 + cx2) // 2
            cy = (cy1 + cy2) // 2
            cv2.line(img, (cx1, cy1), (cx2, cy2), (255, 0, 0), 2)
            cv2.circle(img, (cx, cy), 2, (0, 0, 255), 2)
            mouseLoc = (sx - (cx * sx // camx), cy * sy // camy)
            mouse.position = mouseLoc
            while mouse.position != mouseLoc:
                pass
        elif (len(conts) == 1):
            x, y, w, h = cv2.boundingRect(conts[0])
            if (pinchFlag == 0):
                pinchFlag = 1
                #mouse.press(Button.left)
    cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
    cx = x + w // 2
    cy = y + h // 2
    cv2.circle(img, (cx, cy), (w + h) // 4, (0, 0, 255), 2)
    mouseLoc = (int(sx - (cx * sx // camx)), int(cy * sy // camy))
    mouse.position = mouseLoc
    while mouse.position != mouseLoc:
        pass
    cv2.imshow("cam", img)
    cv2.waitKey(5)


btn = Button(root, text="Show")
btn.pack()
btn.bind('<Button-1>', mouseFunc)
コード例 #7
0
def run_data(data, offset):  #this method needs a refactor
    global m  #MouseController must be global because we write to m.position
    global pressed  #must be global so we can access it in context managers
    global hotKey
    timeElapsed = data[-1]["time_ms"] - data[0]["time_ms"]
    pressed = []
    startTime = time_ms()

    for i, d in enumerate(data):

        if (hotKey == "quit"):
            quit()

        while (hotKey == "pause"):
            time.sleep(.50)

        code = d["code"]
        timeStamp = d["time_ms"]
        try:
            sleep = data[i + 1]["time_ms"] - timeStamp
            if (sleep < 0):
                sleep = 0
        except:  #either the data is invalid or it's the last step
            sleep = 0

        sleep = sleep / 1000  #ms
        time.sleep(sleep)

        mods = list(set(pressed).intersection(MODIFIER_KEYS))
        if (mods is None):
            mods = []

        if (code == 0):
            try:
                x = offset[0] - int(d["data_0"])
                y = offset[1] - int(d["data_1"])
            except:
                pass
            m.position = (x, y)

        elif (code in [1, 2]):
            try:
                x = offset[0] - int(d["data_0"])
                y = offset[1] - int(d["data_1"])
                button = d["data_2"]
            except:
                pass

            if (button == "Button.left"):
                button = Button(1)
            elif (button == "Button.middle"):
                button = Button(2)
            elif (button == "Button.right"):
                button = Button(3)

            with holdKeys(mods):
                if (code == 1):
                    m.press(button)
                    print("click @ ", (x, y), button)

                elif (code == 2):
                    m.release(button)

        elif (code in [4, 5]):
            try:
                key = (d["data_0"])
            except:
                e = sys.exc_info()
                print('error with', e, "invalid keypress")
            if (len(key.replace("'", "")) == 1):  #is not a special key
                try:
                    if (code == 4):
                        if (key in pressed):
                            k.touch(KeyCode.from_char(key.replace("'", "")),
                                    True)
                        else:
                            k.press(KeyCode.from_char(key.replace("'", "")))
                            pressed.append(key)
                    elif (code == 5):
                        k.release(KeyCode.from_char(key.replace("'", "")))
                        if (key in pressed):
                            pressed.remove(key)

                except:
                    e = sys.exc_info()
                    print('error with', e)
            else:
                try:
                    if (code == 4):
                        if (key in pressed):
                            k.touch(_xorg.Key[key], True)
                        else:
                            key = key.split(".")[1].strip('"')
                            k.press(_xorg.Key[key])
                            pressed.append(key)
                    elif (code == 5):
                        key = key.split(".")[1].strip('"')
                        k.release(_xorg.Key[key])
                        if (key in pressed):
                            pressed.remove(key)
                except:
                    e = sys.exc_info()
                    print('error with', e)
            print("pressed key: ", key)

    print("Runtime: ", time_ms() - startTime, " Expected: ", timeStamp)
コード例 #8
0
        while mouse.position != mouseLoc:
            pass
    elif (len(conts) == 1):
        x, y, w, h = cv2.boundingRect(conts[0])
        if (pinchFlag == 0):
            pinchFlag = 1
            #mouse.press(Button.left)
        cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
        cx = int(x + w / 2)
        cy = int(y + h / 2)
        #  cv2.circle(img, (cx, cy), int((w + h) / 4), (0, 0, 255), 2)
        mouseLoc = (sx - (cx * sx / camx), cy * sy / camy)
        mouse.position = mouseLoc
        while mouse.position != mouseLoc:
            pass
    cv2.imshow("cam", img)
    k = cv2.waitKey(5)
    if k == 27:
        break

    if (k == ord('a')):
        cv2.destroyAllWindows()
        root.overrideredirect(1)
        Button(
            root,
            text='Click Me !',
            image=photo,
            command=lambda: alexa_assistant.start_assistant()).pack(side=TOP)
        root.bind('<Alt-Key-F4>', ignorekey())
        root.mainloop()
コード例 #9
0
                 text="Use IP Webcam",
                 font=("Arial", 20, "bold"),
                 fg="black",
                 bg="white").place(x=35, y=60)
ip_desc = Label(root,
                text="Enter IP Address",
                font=("Arial", 10, "bold"),
                fg="#303030",
                bg="white").place(x=38, y=100)
ip_address = Entry(root, font=("times new roman", 11), bg="lightgray")

ip_address.place(x=40, y=125, width=200, height=35)
ip_submit = Button(root,
                   command=ip_webcam,
                   cursor="hand2",
                   text="Start",
                   fg="white",
                   bg="#d77337",
                   font=("Arial", 20)).place(x=60, y=180, width=160, height=40)

title_webcam = Label(root,
                     text="Use Webcam",
                     font=("Arial", 20, "bold"),
                     fg="black",
                     bg="white").place(x=370, y=60)
web_submit = Button(root,
                    command=builtin_webcam,
                    cursor="hand2",
                    text="Start",
                    fg="white",
                    bg="#d77337",