title: Python not reading file/ executing code properly
body: <p>I have a strange problem which I'm not sure why is occurring. </p>
  
  <p>In a game, I type a command (::pos) which writes the positional coords to a .txt file. When I try automate this process (using win32com to type the command) and read the file, the previous coords are displayed instead of the current ones. This makes no sense as I update the coords before displaying them:</p>
  
  <pre><code>def add(self):
      id = self.myTextInput.text()
      shell.AppActivate('App title')
      # Update position file
      shell.SendKeys('::pos')
      shell.SendKeys('{ENTER}')
      # Add object
      shell.SendKeys('::object ' + id + ' 0')
      shell.SendKeys('{ENTER}')
      # Read position
      with open('.txt file path', 'r') as f:
          f = f.read().split()
          self.listWidget.addItem(id + ' ' + f[1] + ' ' + f[3] + ' 0')
  </code></pre>
  
  <p>The code is executed upon pressing a button 'add'. The weird thing is that it all works fine if I create a separate button and function called 'updatePos' (which I press before pressing 'add') but doesn't work if I just call the updatePos() function within add. I have also tried using sleeps to stagger commands but that seems to work strangely too (sleeps block of code before it, not sure if its the shell commands messing with it?).</p>
  
  <p>I think the code is executing in an abnormal order perhaps? E.g. opening and reading text file before the position is updated - but not sure why this is happening.</p>