#region: - Option Opt('MustDeclareVars', 1) Opt('TrayIconDebug', 1) Opt('TrayIconHide', 0) #endregion #include <file.au3> Global $iPid, $iHwd Global $sFilePath = 'c:\test.txt' Global $aFileText = _FileReadToArray($sFilePath) If @error Then MsgBox(16, 'Внимание', 'Ошибка чтения файла: ' & @error) _Pro_Exit() EndIf $iPid = Run('notepad.exe') Do $iHwd = _ProcessGetWindow($iPid) Until IsHWnd($iHwd) WinWait($iHwd) ControlSetText($iHwd, '', '[CLASS:Edit; INSTANCE:1]', $aFileText[Random(0, UBound($aFileText )-1) ]) Func _Pro_Exit() Exit EndFunc Func _ProcessGetWindow($iPID, $iRet=1) Local $aWinList = WinList() Local $aRet[2] If IsString($iPID) Then $iPID = ProcessExists($iPID) For $i = 1 To UBound($aWinList)-1 If WinGetProcess($aWinList[$i][1]) = $iPID Then $aRet[0] = $aWinList[$i][0] ;Title $aRet[1] = $aWinList[$i][1] ;WinHandle If $iRet = 0 Then Return $aRet[0] If $iRet = 1 Then Return $aRet[1] Return $aRet EndIf Next Return SetError(1, 0, $aRet) EndFunc |