I tried to automate the task of entering numbers from 1 to 50 into a web browser with Python.
Made with Python3 on Windows. The required libraries are included in the Anaconda distribution from the beginning, but if it is installed from the Python official website and win32com.client cannot be imported, install the required libraries with the following command.
> pip install pypiwin32
sr50.py
import time
import win32com.client
def main():
wshell = win32com.client.Dispatch('WScript.Shell')
#Make the launched Firefox browser the active window
wshell.AppActivate('Firefox')
#for test
#shell.AppActivate('Notepad')
#Wait 1 second
time.sleep(1)
#50 loops
for cnt in range(50):
#Shift the counter value by 1
cnt+=1
#Wait 2 seconds for continuous input measures
time.sleep(2)
#For confirmation
print(cnt)
#50 count key output
wshell.SendKeys(str(cnt) + '\n')
if __name__ == '__main__':
main()
Open the SHOWROOM screen in your browser in advance and move the cursor to the text box. Then run the Python script below to start counting 50.
The browser is made for Firefox, but I think that it can be supported by other browsers by changing the argument of AppActivate.
SHOWROOM What is SHOWROOM's "count"? Summary of the meaning and effect of 50 counts @IT Introduction to Windows Script Host for Windows Administrators