Aditya
Aditya

Reputation: 29

Autopy mouse automation process

I'm trying to automate a process in which my mouse/cursor moves in a loop and writes a value (which is in this loop).

autopy.mouse.move(800,350) 
time.sleep(0.75)
autopy.mouse.click(LEFT_BUTTON)
autopy.mouse.click(LEFT_BUTTON)
time.sleep(2.0)
autopy.key.type_string("100")
time.sleep(1.0)

Is there a way in which I can use "autopy.key.type_string("100")" to change nos in this loop.

For eg. 100, 200, 300 . . . .1000 and so on.

Since, autopy only takes strings, I'm unable to do so. Please, let me know, if you've an idea about this.

Upvotes: 0

Views: 959

Answers (3)

haxor789
haxor789

Reputation: 614

for i in range(0, 1001, 100):
    autopy.mouse.move(800,350) 
    time.sleep(0.75)
    autopy.mouse.click(LEFT_BUTTON)
    autopy.mouse.click(LEFT_BUTTON)
    time.sleep(2.0)
    autopy.key.type_string(f"{i}") # this line 
    time.sleep(1.0)

Nowadays you'd have format strings for that

Upvotes: 0

ali naderi
ali naderi

Reputation: 19

for i in range(0,1000,100):
    autopy.mouse.smooth_move(800,350) 
    time.sleep(0.75)
    autopy.mouse.click()
    autopy.mouse.click()
    time.sleep(2.0)
    autopy.key.type_string(str(i))
    time.sleep(1.0)

smooth_move for slow move

Upvotes: 0

王振武
王振武

Reputation: 11

a=100
autopy.key.type_string('%d'%a)

I hope it can help you.

Upvotes: 0

Related Questions