Всем доброго времени суток! Есть такой пример:
Можно ли обрабатывать события похожим образом для уже запущенных приложений Word, Excel, PowerPoint?
Код:
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <Excel.au3>
#include <Constants.au3>
#include <MsgBoxConstants.au3>
; *****************************************************************************
; Example Script (from here https://www.autoitscript.com/forum/topic/177742-excel-open-and-wait-for-user-to-close-it/)
; Handle Excel worksheet change event when a cell has been changed and set the
; color of the cell to red.
; This script loops until Shift-Alt-E is pressed to exit.
; *****************************************************************************
#CS HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script
; MsgBox(64, "Excel UDF: Events Example", "Hotkey to exit the script: 'Shift-Alt-E'!")
#CE
; Create application object and open a workbook
Global $oAppl = _Excel_Open()
If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: Events Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Global $oWorkbook = _Excel_BookNew($oAppl)
If @error <> 0 Then
MsgBox($MB_SYSTEMMODAL, "Excel UDF: Events Example", "Error opening workbook '_Excel2.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_Excel_Close($oAppl)
Exit
EndIf
ObjEvent($oWorkbook, "Workbook_")
While 1
Sleep(10)
WEnd
Exit
; Excel - Workbook BeforeClose event - https://msdn.microsoft.com/en-us/library/ff839916%28v=office.14%29.aspx
Volatile Func Workbook_BeforeClose(ByRef $bCancel)
#forceref $bCancel
If MsgBox(BitOR($MB_YESNO, $MB_ICONQUESTION), "Close?", "Should the Workbook be closed?") = $IDNO Then $bCancel = True
EndFunc ;==>Workbook_BeforeClose
Func _Exit()
Exit
EndFunc ;==>_Exit
Можно ли обрабатывать события похожим образом для уже запущенных приложений Word, Excel, PowerPoint?