Thursday, 2 January 2020

Pywinauto timings waiting 0.5 seconds instead of immediate

I have the following Pywinauto code and timings waiting is 0.5 seconds instead of immediate. How to get itimmediately?

  • To click a button and go to the next message:
from pywinauto import application, timings, mouse
import time

app = application.Application()
app.connect(title = 'Mensagem')
app = app.Mensagem
app2 = app.TBPanel2
buttonCoord = int((app2.rectangle().right - app2.rectangle().left)/2/2), int((app2.rectangle().bottom - app2.rectangle().top)/2)
buttonCoord = buttonCoord[0]*(2*2-1),buttonCoord[1]
timings.Timings.after_clickinput_wait = 0.001
timings.Timings.after_setcursorpos_wait = 0.001

starttime = time.perf_counter()
#while app.Edit1.texts()[0] != '':
for i in range(10):
    buttonCoord = int((app2.rectangle().right - app2.rectangle().left)/2/2), int((app2.rectangle().bottom - app2.rectangle().top)/2)
    buttonCoord = buttonCoord[0]*(2*2-1),buttonCoord[1]
    app2.click_input(button='left', coords=(buttonCoord))
    print('Entre cliques demorou ', str(time.perf_counter()-starttime), ' segundos')
    starttime = time.perf_counter()

When I run, the interval between clicks is 0.5 seconds:

Entre cliques demorou  0.4614592999999999  segundos
Entre cliques demorou  0.44403170000000003  segundos
Entre cliques demorou  0.48520320000000017  segundos
Entre cliques demorou  0.4723533999999998  segundos
Entre cliques demorou  0.46825479999999997  segundos
Entre cliques demorou  0.4439942000000001  segundos
Entre cliques demorou  0.4874373999999997  segundos
Entre cliques demorou  0.47333040000000004  segundos
Entre cliques demorou  0.46036510000000064  segundos

However, when I move my mouse frantically, it goes faster:

Entre cliques demorou  0.06659199999999998  segundos
Entre cliques demorou  0.1532768000000001  segundos
Entre cliques demorou  0.05349690000000007  segundos
Entre cliques demorou  0.049827499999999914  segundos
Entre cliques demorou  0.05078930000000015  segundos
Entre cliques demorou  0.04885250000000019  segundos
Entre cliques demorou  0.06023690000000004  segundos
Entre cliques demorou  0.048675000000000024  segundos
Entre cliques demorou  0.05394080000000012  segundos
Entre cliques demorou  0.05615450000000011  segundos

What exactly am I doing wrong?



from Pywinauto timings waiting 0.5 seconds instead of immediate

No comments:

Post a Comment