I am making this small program, where the user can input the x and y axis of the screen where they wish to move the mouse to, and how many time they would like to click on that pixel.
My problem is when I try to put the variables into this function, the arguments apparently cannot be converted? The SetCurPos() is the problem, it will take SetCurPos(x,y), but I receive the error:
File "C:\Python27\Scripts\ManipulationTools.py", line 13, in click
SetCursorPos(x,y)
ArgumentError: argument 1: : Don't know how to convert parameter 1
My Code:
from Tkinter import *
import time
import ctypes
#from MoveCursor import click
class ManipulationTools():
##############FUNCTIONS###################################
def click(x,y, numclicks):
SetCursorPos = ctypes.windll.user32.SetCursorPos
mouse_event = ctypes.windll.user32.mouse_event
SetCursorPos(x,y)
E1.DELETE(0, END)
E2.DELETE(0, END)
E3.DELETE(0, END)
for i in xrange(numclicks):
mouse_event(2,0,0,0,0)
mouse_event(4,0,0,0,0)
#############END FUNCTIONS################################
root = Tk()
root.maxsize(width=400, height=400)
root.minsize(width=400, height=400)
root.config(bg="black")
L1 = Label(root,text="Enter the x and y value here:", fg="white", bg="black")
L1.place(x=20, y=20)
Lx = Label(root, text="X:",fg="white",bg="black")
Lx.place(x=170,y=20)
Ly = Label(root, text="Y:",fg="white",bg="black")
Ly.place(x=240,y=20)
Lnum = Label(root, text="Number of Times:",fg="white",bg="black")
Lnum.place(x=150, y=100)
E1 = Entry(root, width=5, bg="grey", )
E1.place(x=190,y=20)
E2 = Entry(root, width=5, bg="grey",)
E2.place(x=260,y=20)
E3 = Entry(root, width=5, bg="grey",)
E3.place(x=260,y=100)
a=IntVar(E1.get())
b=IntVar(E2.get())
c=IntVar(E3.get())
con = Button(root, command=click(a,b,c), text="Confirm", bg="white")
con.place(x=300,y=300)
root.mainloop()
My Traceback error when I click the button to confirm the numbers in the fields entered:
Traceback (most recent call last):
File "C:\Python27\Scripts\ManipulationTools.py", line 6, in
class ManipulationTools():
File "C:\Python27\Scripts\ManipulationTools.py", line 53, in ManipulationTools
con = Button(root, command=click(a,b,c), text="Confirm", bg="white")
File "C:\Python27\Scripts\ManipulationTools.py", line 13, in click
SetCursorPos(x,y)
ArgumentError: argument 1: : Don't know how to convert parameter 1