Global $iTop = 30
Global $aInstances[6][3] = [[5]]
Global $sSet_Data = 'Notepad Instance #%i'
Global $sNotepad_WinCLASS = '[REGEXPCLASS:Notepad.*]'
Global $sNotepad_EditCLASS = 'Edit1'
$hGUI = GUICreate('__Simultanius_Run_Handling_GUI__')
$nEdit = GUICtrlCreateEdit('', 0, 0, 200, 200)
For $i = 1 To $aInstances[0][0]
$iNotepad_PID = Run('Notepad.exe')
If @error Then ContinueLoop
While 1
$aWinList = WinList($sNotepad_WinCLASS)
For $x = 1 To UBound($aWinList) - 1
If WinGetProcess($aWinList[$x][1]) = $iNotepad_PID Then
$hNotepad = $aWinList[$x][1]
ExitLoop 2
EndIf
Next
WEnd
If Not IsHWnd($hNotepad) Then ContinueLoop
$aWin_Pos = WinGetPos($hNotepad)
WinMove($hNotepad, '', $aWin_Pos[0], $iTop)
$iTop += 100
$sRun_Script_Content = _
'#NoTrayIcon' & @CRLF & _
'While ControlGetText(Hwnd(' & $hGUI & '), "", "Edit1") <> "Notepad Instances = ' & $aInstances[0][0] & '"' & @CRLF & _
' Sleep(10)' & @CRLF & _
'WEnd' & @CRLF & _
'ControlSetText(Hwnd(' & $hNotepad & '), "", "' & $sNotepad_EditCLASS & '", "EditPaste", StringFormat("' & $sSet_Data & '", ' & $i & '))' & @CRLF
$sFile = @TempDir & '\~Au3_Run_' & $i & '.Tmp'
$hFOpen = FileOpen($sFile, 2)
FileWrite($hFOpen, $sRun_Script_Content)
FileClose($hFOpen)
$iAU3_PID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sFile & '"')
If $i = $aInstances[0][0] Then
MsgBox(64, 'Attention...', 'Now we will see the data set almost in the same time in all [' & $i & '] Notepads...', 3)
Sleep(500)
EndIf
GUICtrlSetData($nEdit, 'Notepad Instances = ' & $i)
$aInstances[$i][0] = $iNotepad_PID
$aInstances[$i][1] = $iAU3_PID
$aInstances[$i][2] = $sFile
Next
Sleep(2000)
MsgBox(64, 'Attention...', 'Now we need to clean a little :) (delete temporary files and close Notepad windows)...', 5)
Opt('WinWaitDelay', 10)
For $i = $aInstances[0][0] To 1 Step -1
ProcessClose($aInstances[$i][0])
ProcessClose($aInstances[$i][1])
FileDelete($aInstances[$i][2])
Next