Reputation: 23
Actually, I have written a code where I've to lunch the application such that I've to click the on-screen keyboard using this pyautogui.click()
. But it is not working on on-screen keyboard. I'll be pleased to have your precious opinion. Thanks in advance.
import os
import pyautogui as pg
import time
x= 195
y=505
secret="secretpassword"
command = "application"
os.system(command)
pg.click(x, y)
pg.typewrite(secret)
pg.typewrite(["enter"])
If the application is already lunched this is working but i want to lunch it with os.system(command) and after that enter my password and access to the application.
Am I doing something wrong ?
Upvotes: 1
Views: 4215
Reputation: 23
I changed
os.system(command)
with
subprocess.Popen(command)
Now it's working
subprocess.Popen() is strict super-set of os.system().
Upvotes: 1
Reputation: 912
os.system()
will block and wait for the application to exit.
This means that your click, in fact, will not execute until the opened appication closes.
To verify this, you can open a (python) shell and run following code:
import os
import pyautogui
def test():
os.system('<something simple opening a window>')
pyautogui.typewrite("I'm in the shell again!")
test()
To run your script as you want, use os.popen
, or, even better, subprocess.Popen
. These will run the command without blocking.
If you do this, keep in mind your application will have startup time, so you will want to wait some time after the call as noted in the comments under your question.
Upvotes: 0