【问题标题】:Unable to type username in an application after opening it from cmd using subprocess使用子进程从 cmd 打开应用程序后无法在应用程序中键入用户名
【发布时间】:2018-04-08 14:41:06
【问题描述】:

我想打开一个应用程序并在该应用程序中输入用户名。 但是在关闭该应用程序后,我的用户名也在命令窗口中输入。 如果我取消注释下面的注释行,则不会输入用户名(没有其他应用程序打开)。

请帮忙。

  import subprocess, pyautogui
  subprocess.call('C:/a-b/a-b.exe')
  pyautogui.typewrite('username'+ '\t')

【问题讨论】:

    标签: python-3.x subprocess pyautogui


    【解决方案1】:

    我不明白为什么上面的代码不起作用。但是,我找到了另一种执行所需任务的方法:

    import pyautogui, time
    pyautogui.hotkey('ctrl', 'esc');
    pyautogui.typewrite('a-b');
    time.sleep(0.5)
    pyautogui.press('enter')
    time.sleep(1)
    pyautogui.typewrite('username' + '\t');
    pyautogui.typewrite('password' + '\t');
    pyautogui.press('enter')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-16
      • 1970-01-01
      相关资源
      最近更新 更多