title: How to stop or pause pyautogui at any moment that I want?
body: <p>I am building some macro program using pyautogui.</p>
  <p>Unfortunately I am not able to stop for-loop so sometimes it takes too much time until for-loop end.
  Is there any way to stop the program at any moment I want? or I just wait until program end.</p>
  <h2>below is my code</h2>
  <pre><code>CURRENT_DIR = os.getcwd()
  list = os.path.join(CURRENT_DIR,'BOM_list.xlsx')
  df = pd.read_excel(list)
  
  for i in df['MLFB'].index:
      MLFB = df.loc[i, 'MLFB']
      print(MLFB)
      a = pyautogui.locateCenterOnScreen('a_material.png')
      print(a)
      pyautogui.moveTo(a)
      pyautogui.moveRel(350, 0)
      pyautogui.click()
      pyautogui.keyDown('ctrl')
      pyautogui.press('a')
      pyautogui.keyUp('ctrl')
      pyautogui.typewrite(MLFB)
      b = pyautogui.locateCenterOnScreen('b_execute.png')
      print(b)
      pyautogui.moveTo(b)
      pyautogui.click()
      time.sleep(2.5)
      pyautogui.keyDown('alt')
      pyautogui.press('y')
      pyautogui.press('t')
      pyautogui.press('a')
      pyautogui.press('i')
      pyautogui.keyUp('alt')
      time.sleep(2)
      pyautogui.press('down')
      pyautogui.typewrite(['enter'])
      time.sleep(2)
  
      c = pyautogui.locateCenterOnScreen('c_Directory.png')
      pyautogui.moveTo(c)
      pyautogui.moveRel(350, 0)
      pyautogui.click()
      pyautogui.keyDown('ctrl')
      pyautogui.press('a')
      pyautogui.keyUp('ctrl')
      pyautogui.typewrite(CURRENT_DIR)
      pyautogui.click()
      time.sleep(1.5)
      d = pyautogui.locateCenterOnScreen('d_Filename.png')
      pyautogui.moveTo(d)
      pyautogui.moveRel(350, 0)
      pyautogui.click()
      pyautogui.keyDown('ctrl')
      pyautogui.press('left')
      pyautogui.keyUp('ctrl')
  
      pyautogui.typewrite(MLFB)
  
      time.sleep(0.5)
      pyautogui.typewrite(['enter'])
      time.sleep(2)
  
      e = pyautogui.locateCenterOnScreen('e_go_back.png')
      pyautogui.moveTo(e)
      pyautogui.click()
      time.sleep(2)
  </code></pre>