Dilip Anand
Dilip Anand

Reputation: 35

why program isn't running any output,?

I need the mouse go the below given axis infinitely, until i break the program.

import pyautogui, time

for i in range(0):
    pyautogui.moveTo(716, 234, duration = 2)
    pyautogui.moveTo(234, 600, duration = 2)
    time.sleep(2)

Upvotes: 1

Views: 52

Answers (2)

Daniel
Daniel

Reputation: 576

Your for loop

for i in range(0):

runs 0 times, the code in the for loop will therefore not execute. If you want the for loop to run n times you can't change the value of 0 to n.

n = 3
for i in range(n):
    print("Hello!")

The above loop will output:

Hello!
Hello!
Hello!

If you need the mouse go the below given axis infinitely, until you break your program, you can use a while True loop instead.

while True:
    print("hello")

Upvotes: 0

David sherriff
David sherriff

Reputation: 476

Your for loop conditions are never met so your command to pyautogui are never called. If you need an infinite loop use 'while True:'

Upvotes: 1

Related Questions