Reputation: 284
Here's my code. When I run it the return statement doesn't return anything. Anyone know why?
import win32api as win
import time
import sys
def mouse_path(run):
path = []
while time.clock() < run:
cords = (win.GetCursorPos())
time.sleep(.1)
path.append(cords)
return path
mouse_path(10)
Upvotes: 0
Views: 55
Reputation: 36598
It looks like you are running this from a .py file and not in interactive mode. Objects that come back from a return
statement are not displayed except in interactive mode. Try wrapping the returned values in a print
statement.
import win32api as win
import time
import sys
def mouse_path(run):
path = []
while time.clock() < run:
cords = (win.GetCursorPos())
time.sleep(.1)
path.append(cords)
return path
print(mouse_path(10))
I ran it and this was printed to screen:
[(514, 469), (545, 474), (606, 465), (654, 444), (705, 430), (754, 425), (795, 423),
(825, 426), (821, 443), (794, 466), (774, 472), (733, 468), (679, 421), (622, 379),
(578, 330), (540, 305), (489, 277), (442, 284), (424, 310), (417, 323), (425, 346),
(460, 375), (512, 417), (563, 422), (610, 377), (677, 317), (733, 291), (787, 298),
(817, 328), (824, 368), (823, 401), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419), (812, 419),
(812, 419)]
Upvotes: 3