As already mentioned in my comment:
Never use
SendMessage
when the receiving window is not owned by the thread sending the message. Use
PostMessage
instead. There should be also no need to set a repeat count of one. Try this instead:
::PostMessage(g_hwndConsole, WM_CHAR, scriptPath[i], 0);