Trying to run AutoIt file from Python

I tried to reproduce your issue and copied your Python code and create stub functions for AutoIt functions (see code snippets and possible solution below).

First of all, current version of main() Python function has syntax error (the quotation mark should be on the first line in call os.system(). I didn’t manage to edit description). Check your local code (use double backslashes as editor suggested you.). But this is not a cause of issue because you would have seen the error “SyntaxError: EOL while scanning string literal” in terminal

As you said, manually running AutoIt script works fine and you don’t see any error in terminal. So I guess that cause in executing of RealMain.exe file. Some antivirus apps block execution of such executable files that operates with important files and folders (user Downloads folder in your case). For example when I tested your code my Windows Security app suggested me to send them this compiled .exe (by Aut2exe.exe utility) and check it. You could miss a blocking notification from your antivirus.

Try to substitute your .exe file to not compiled .au3 file and check result. i.e.

os.system("D:\\tmp\\tmp_autoit\\RealMain.au3 " 
+ "Record@"+Exe_file_dir)

But don’t forget that default shell behaviour for .au3 files must be ‘Run’, not ‘Edit’. You can check it in advance by double clicking on RealMain.au3 file. But watch for antivirus notification, because AutoIt3.exe also can be blocked.

Also check carefully how and where you run your Python script (adding if __name__ == "__main__": block at the end of script is a good practice).

My code snippets to quick reproduce:

# run_real_main_script.py
import os


def main():                   
    Exe_file_dir = "D:\\tmp\\tmp_autoit\\Sample.log"
    os.system("C:\\Users\\myuser\\Downloads\\RealMain.exe " 
    + "Record@"+Exe_file_dir)


if __name__ == "__main__":
    main()
;~ RunMain.au3
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Func RunMain($sFile)
    MsgBox($MB_SYSTEMMODAL, "", "Run RunMain() function" & @CRLF & "$sFile=" & $sFile)
EndFunc
;~ RecordMain.au3
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Func RecordMain($sFile)
    MsgBox($MB_SYSTEMMODAL, "", "Run RecordMain() function" & @CRLF & "$sFile=" & $sFile)
EndFunc

RealMain.au3 is the exact copy of “Autoit code:” snippet in the description.

I executed run_real_main_script.py script with installed Python 3.9.2 interpreter in PowerShell as:

python "D:\tmp\tmp_autoit\check_scripts\run_real_main_script.py"