#include <Misc.au3>
HotKeySet('{Esc}', '_Exit')
If FileExists(@WindowsDir & '\notepad.exe') Then
Run(@WindowsDir & '\notepad.exe')
Else
MsgBox(16, 'Error', 'У Вас нет блокнота')
Exit
EndIf
$hWin = WinWait('[Class:Notepad]', '', 3)
If Not $hWin Then
MsgBox(16, 'Error', 'Error')
Exit
EndIf
While 1
If _IsPressed('04') Then ;средняя кнопка мыши
ControlSend($hWin, '', '[CLASS:Edit;INSTANCE:1]', 'Нажата средняя кнопка мыши {ENTER}')
While _IsPressed('04')
Sleep(50)
WEnd
ControlSend($hWin, '', 'Edit1', 'Отпущена средняя кнопка мыши {ENTER}')
EndIf
If Not WinExists($hWin) Then Exit
Sleep(50)
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit